我在一个包含javascript函数getData()的iframe中有一个完整的html openning.现在我不知道如何从该框架外部调用getData().还可以从外部javascript文件中调用它吗?
在我的网页中,一些图像需要花费大量时间才能在IE中加载.所以我用它来预加载我页面中的图像.但问题仍然存在.任何建议?
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
});
alert("Done Preloading...");
}
// Usage:
preload([
'/images/UI_1.gif',
'/images/UI_2.gif',
'/images/UI_3.gif',
'/images/UI_4.gif',
'/images/UI_5gif',
'/images/UI_6.gif',
'/images/UI_7.gif',
'/images/UI_8.gif',
'/images/UI_9.gif'
]);
Run Code Online (Sandbox Code Playgroud)
<
DIV>
这段代码出了什么问题?只有第一个添加和删除链接正在运行...
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<style type="text/css">
div{
padding:8px;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
var counter = 2;
$(".addButton").click(function () {
if(counter>5){
alert("Only 5 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.html('<TABLE><TR><TD>' +
'<input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" ></TD><TD><input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" ></TD> <TD><a href="#" value="addButton" class="addButton">Add</a> <a href="#" value="removeButton" class="removeButton">Remove</a></TD></TR></TABLE>');
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
$(".removeButton").click(function () …Run Code Online (Sandbox Code Playgroud) 我有这样的代码来获取变量 isItemLocked 的值。
function authorItem(itemNumber){
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
url ="Some URL";
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var isItemLocked = xmlhttp.responseText;
if(isItemLocked){
alert('Item has been Closed.Click OK to go to Search Page');
window.location = "SOME OTHER URL";
}else{
var url ="SOME OTHE URL 1";
location.href = url;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
isItemLocked 的返回布尔值为 true。但每次我要去其他一些 URL 时。有任何解决方案吗?
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script>
chrome.browserAction.onClicked.addListener(function(tab) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var $ajaxData = xhr.responseText;
var hidden = document.createElement ( 'div' );
hidden.id = 'hiddenel';
$("body").append ( hidden );
$("#hiddenel").html ($ajaxData);
var $aa = $("#hiddenel").find('div .somediv');
var notification = webkitNotifications.createNotification(
'some msg',
'some msg',
$aa.html());
notification.show();
} else {
alert("Unable to connect...");
}
}
}
var url = some url;;
xhr.open('GET', url, true);
xhr.send();
}); …Run Code Online (Sandbox Code Playgroud) 我有一个像javascript一样的数组
["1.A","1.B","1.C","1.D",...,"2.A","2.B",...]
Run Code Online (Sandbox Code Playgroud)
现在我想通过指定的字符串从这个数组中删除元素.对于exm如果我指定"1"那么它应该删除所有"1.A","1.B","1.C","1.D"....如何在jQuery中执行此操作.
我有一个自定义对象数组CustomClass [] customArr,其中CustomClass就像
Class CustomClass{
private String key;
private String value;
//getter & setters
}
Run Code Online (Sandbox Code Playgroud)
现在我想通过一个特定的值搜索这个数组.最好的方法是什么?
我希望我的用户在说15分钟后看到一个确认框,提醒他们会话超时.我希望这个过程重复继续.即使用户从确认框中选择取消,他也会在15分钟后得到相同的警报.