总体意思有点理解,具体意思没看懂。。不过意思我理解你问的问题。。
你是说那个是全局变量。。每个第二张图片会影响第一张图片对吧?
这个好弄啊。用OBJECT,或者闭包即可。
你是说那个是全局变量。。每个第二张图片会影响第一张图片对吧?
这个好弄啊。用OBJECT,或者闭包即可。
解决方案 »
- 正则换出所有<img 标签,并替换src路径,怎么弄?
- 点击add按钮的时候怎么没反应
- google map最大路标数问题
- document.getElementById("attach0").style.backgroundColor 得不到背景色
- 在线等,大家赶紧帮帮忙啊~急~~~一个关于框架的问题
- 如何将获得的一段文字分成2段放入2个文本框里
- 如何用改变样式
- 如何设置“放于层内的”层的left和top为相对于屏幕的值?
- 是否可以通过调用Applet的函数返回值,由JavaScript来显示。
- 我想请问javascript高手:如何在一个块中动态的改变其中的文字.我的信箱是[email protected]
- 急送分·超简单js问题!
- 最后40分请教:如何刷新页面?谢谢大家,什么我的不能
div {
width:200px;
height:40px;
line-height:40px;
background-color:#CCCCCC;
border:#000000 3px solid;
margin-top:5px;
}
</style>
<script type="text/javascript">
window.onload = function () {
var i, crobj = function (i) {
var div = document.createElement("div"), time;
div.innerHTML = i;
div.onmouseover = function () {
time = window.setTimeout("alert('" + i + "被P了2S')", 2000);
};
div.onmouseout = function () {
window.clearTimeout(time);
};
return div;
};
for (i = 0 ; i < 5 ; i ++) {
document.body.appendChild(crobj(i));
}
};
</script>
div {
width:200px;
height:40px;
line-height:40px;
background-color:#CCCCCC;
border:#000000 3px solid;
margin-top:5px;
}
</style>
<script type="text/javascript">
var crobj = function (i) {
var wc = this, div;
wc.time = 0;
(div = wc.div = document.createElement("div")).innerHTML = (wc.number = i);
div.onmouseover = function () {
wc.over();
}
div.onmouseout = function () {
wc.out();
};
return div;
};crobj.prototype = { over : function () {
this.time = window.setTimeout("alert('" + this.number + "被P了2S')", 2000);
},
out : function () {
window.clearTimeout(this.time);
}
};
window.onload = function () {
for (var i = 0 ; i < 5 ; i ++)
document.body.appendChild(new crobj(i));
};
</script>
var tileArray = visibleTiles[i];
var tileName = tileArray[1] + "_" + tileArray[0];
visibleTilesMap[tileName] = true;
var img = document.getElementById(tileName);
if (!img) {
img = document.createElement("img");
img.src="../i/"+ tileName+ ".gif";
img.style.position = "absolute";
img.style.left = (tileArray[0] * tileSize) + "px";
img.style.top = (tileArray[1] * tileSize) + "px";
img.style.zIndex = 0;
img.setAttribute("id", tileName);
img.onclick = function () {
maptitle(this);
}
(function () {
var isDelay;
img.onmouseover = function () {
isDelay=setTimeout(mapover(this),2000);
}
img.onmouseout = function () {
clearTimeout(isDelay);
}
})();
innerDiv.appendChild(img);
}
}
var crobj = function (i) {
var wc = this, div;
wc.time = 0;
(div = wc.div = document.createElement("div")).innerHTML = (wc.number = i);
div.onmouseover = function () {
wc.over();
}
div.onmouseout = function () {
wc.out();
};
return div;
};crobj.prototype = {over : function () {
this.time = window.setTimeout("alert('" + this.number + "被P了2S')", 2000);
},out : function () {
window.clearTimeout(this.time);
}};
window.onload = function () {
for (var i = 0 ; i < 5 ; i ++)
document.body.appendChild(new crobj(i));
};
</script>----
wc = this既然.,那么this.over()这么写为什么不行..这几个this弄不明白.
wc.over();
}
div.onmouseout = function () {
wc.out();
};
因为这个函数里的this就变成了div。而不是wc那个this,所以不行。
img.onmouseover=function(){isDelay=setTimeout(mapover(this),2000);}
这里在循环后只会对最后一个有效
就是当用户把鼠标放在图片上时,用ajax取数据库信息显示出来
这种方法不是很好
for (i=0;i<5;i++){
var div = document.createElement("div"),time;
div.innerHTML = i;
div.onmouseover = new Function ("time=window.setTimeout('alert("+i+")', 2000)");div.onmouseout = function () {
window.clearTimeout(time);
};
document.body.appendChild(div);
}
</script>