<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>demo</title>
</head><body><div id="personalMessage" style="position:absolute; width:221px; height:625px; z-index:1; left: 274px; top: 71px; overflow: hidden;background-color:yellow">
</div>
<div id="suolue" style="position:absolute; width:440px; height:141px; z-index:1; left: 572px; top: 45px; border: 1px none #000000;;background-color:pink">
</div>
<div id="mainDesign" style="top:207px; left:519px; width:588px; height:493px; color: #00FFFF; position:absolute"> <div id="contralTool" style="position:absolute; width:492px; height:28px; z-index:3; left: 38px; top: 39px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="addElement" style="position:absolute; width:492px; height:24px; z-index:4; left: 38px; top: 67px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="front" style="position:absolute; width:500px; height:288px; z-index:5; left: 28px; top: 142px; border: 1px none #000000;overflow:hidden">
</div></div>
<script type="text/javascript">
var front = document.getElementById('front');for(var i=0;i<5;i++)
{
var div = createDiv(i);
front.appendChild(div);
}function createDiv(i)
{
var div = document.createElement("div");
div.id = i
div.style.width =300+ "px";
div.style.height = 15 + "px";
div.style.position = "absolute";
div.style.top = 100+i*10 + "px";
div.style.left = 100+i*10+ "px";
div.onmouseover = listenerPrompt;
div.onmouseout = cancelPrompt;
return div;
}function listenerPrompt()
{
this.style.border = "dashed 1px blue";
this.style.cursor = "move";
}function cancelPrompt()
{
this.style.border = "dashed 0px blue";
this.style.cursor = "move";
}
</script>
</body>
</html>我给front这个div加了几个子div,这些子div有onmouseover跟onmouseout事件。鼠标过div时就出现边框,离开边框就消失,但是按照上面的代码,根本不会触发事件,但是如果给front这个div加上一个背景色,或者给子div本身加上背景色,那就可以正确的触发事件了,这是怎么回事呢?怎么样能让不加背景色也可以正常触发事件呢?
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>demo</title>
</head><body><div id="personalMessage" style="position:absolute; width:221px; height:625px; z-index:1; left: 274px; top: 71px; overflow: hidden;background-color:yellow">
</div>
<div id="suolue" style="position:absolute; width:440px; height:141px; z-index:1; left: 572px; top: 45px; border: 1px none #000000;;background-color:pink">
</div>
<div id="mainDesign" style="top:207px; left:519px; width:588px; height:493px; color: #00FFFF; position:absolute"> <div id="contralTool" style="position:absolute; width:492px; height:28px; z-index:3; left: 38px; top: 39px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="addElement" style="position:absolute; width:492px; height:24px; z-index:4; left: 38px; top: 67px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="front" style="position:absolute; width:500px; height:288px; z-index:5; left: 28px; top: 142px; border: 1px none #000000;overflow:hidden">
</div></div>
<script type="text/javascript">
var front = document.getElementById('front');for(var i=0;i<5;i++)
{
var div = createDiv(i);
front.appendChild(div);
}function createDiv(i)
{
var div = document.createElement("div");
div.id = i
div.style.width =300+ "px";
div.style.height = 15 + "px";
div.style.position = "absolute";
div.style.top = 100+i*10 + "px";
div.style.left = 100+i*10+ "px";
div.onmouseover = listenerPrompt;
div.onmouseout = cancelPrompt;
return div;
}function listenerPrompt()
{
this.style.border = "dashed 1px blue";
this.style.cursor = "move";
}function cancelPrompt()
{
this.style.border = "dashed 0px blue";
this.style.cursor = "move";
}
</script>
</body>
</html>我给front这个div加了几个子div,这些子div有onmouseover跟onmouseout事件。鼠标过div时就出现边框,离开边框就消失,但是按照上面的代码,根本不会触发事件,但是如果给front这个div加上一个背景色,或者给子div本身加上背景色,那就可以正确的触发事件了,这是怎么回事呢?怎么样能让不加背景色也可以正常触发事件呢?
解决方案 »
- iframe刷新父窗口的问题。大家帮帮忙。。
- fck的GetXHTML()很慢,大家有什么好办法么?
- |zyciis| Jquery Ajax中他有error,success,complete那他的开始请求的方法是哪个
- 求一正则表达式,在线急等,马上给分!!!!!
- 请教几个属性
- 怎么做到页面提交一次就在页面下方表格中增加一行?非常感谢
- [jquery] 选项卡问题,求助高手
- 请帮我看下面的代码!!
- 写一个可以扫描图片的页面.
- 时间输入(HH:MM:SS)的解决方案和参考程序
- 请教大虾,关于gadget的问题
- 请教个问题, 用javascript截屏 屏幕上的位置已确定 用js截完后保存成图片就可以 怎么做呀???????
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>demo</title>
</head><body><div id="personalMessage" style="position:absolute; width:221px; height:625px; z-index:1; left: 274px; top: 71px; overflow: hidden;background-color:yellow">
</div>
<div id="suolue" style="position:absolute; width:440px; height:141px; z-index:1; left: 572px; top: 45px; border: 1px none #000000;;background-color:pink">
</div>
<div id="mainDesign" style="top:207px; left:519px; width:588px; height:493px; color: #00FFFF; position:absolute"> <div id="contralTool" style="position:absolute; width:492px; height:28px; z-index:3; left: 38px; top: 39px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="addElement" style="position:absolute; width:492px; height:24px; z-index:4; left: 38px; top: 67px; background-color: #C3DBFD; layer-background-color: #C3DBFD; border: 1px none #000000;">
</div>
<div id="front" style="position:absolute; width:500px; height:288px; z-index:5; left: 28px; top: 142px; border: 1px none #000000;overflow:hidden;background-color:pink">
</div></div>
<script type="text/javascript">
var front = document.getElementById('front');
var img = createImg("13.png");
front.appendChild(img);for(var i=0;i<5;i++)
{
var div = createDiv(i);
front.appendChild(div);
}function createDiv(i)
{
var div = document.createElement("div");
div.id = i
div.style.width =300+ "px";
div.style.height = 15 + "px";
div.style.position = "absolute";
div.style.top = 100+i*10 + "px";
div.style.left = 100+i*10+ "px";
div.onmouseover = listenerPrompt;
div.onmouseout = cancelPrompt;
return div;
}function listenerPrompt()
{
this.style.border = "dashed 1px blue";
this.style.cursor = "move";
}function cancelPrompt()
{
this.style.border = "dashed 0px blue";
this.style.cursor = "move";
}function createImg(src)
{
var img = new Image();
img.src = src;
img.style.top = 0;
img.style.left = 0;
img.style.position = "absolute";
return img;}
</script>
</body>
</html>
我就给div加上背景色,是可以了,但是我给front div里放了一张图片,就又不行了,到底是怎么回事呢?