一个新手的问题 什么叫 动态拉出一个框?触发onmouseover和onmouseout事件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 前两天回别的帖子的时候做了,给你参考一下。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> <!-- #div1 { position: relative; height: 25px; width: 60px; background-color: #FFD5AA; } #div2 { position: absolute; top: 25px; left: 0px; background-color: #B5FFB5; } --> </style> <script type="text/javascript"> <!-- var stop = null; window.onload = function(){ $("div1").onmouseover = mouseOver; function mouseOver(e){ e = e || window.event; if (stop) { clearTimeout(stop); } $("div2").style.display = "block"; expand($("div2"), "+", 140, "block"); } $("div1").onmouseout = $("div2").onmouseout = function(e){ e = e || window.event; var elFrom = e.fromElement || e.target; var elTo = e.toElement || e.relatedTarget; if ((elFrom.id == "div1" && elTo.id == "div2") || (elFrom.id == "div2" && elTo.id == "div1")) { return; } if (stop) { clearTimeout(stop); } expand($("div2"), "-", 0, "none"); } } function expand(o, fuhao, wh, dis){ if (parseInt(o.style.height) == wh || parseInt(o.style.height) == wh) { clearTimeout(stop); o.style.display = dis; stop = null; return; } eval("var th = parseInt(o.style.height)" + fuhao + "5"); eval("var tw = parseInt(o.style.height)" + fuhao + "5"); o.style.height = th + "px"; o.style.width = tw + "px"; stop = setTimeout(function(){ expand(o, fuhao, wh, dis) }, 10); } function $(oid){ return document.getElementById(oid); } //--> </script> </head> <body> <div id="div1"> <div id="div2" style="width:0px;height:0px;display:none;"> </div> </div> </body></html> 页面里同样的代码,为什么一个运行,一个不运行? 如何用JavaScript修改页面的Title啊? 百思不得解,为何加不加parseInt()函数,差别这个大呢?有代码 图片渐变特效...... 请教一个frame的尺寸改变的问题。 打印全部页面和调用外部exe的问题 万分焦急! 怎么样让层显示滚动条?--很用实用的问题 点击图片,弹出一个新窗口,显示另一个新页面?? 好象无法调用一个动态嵌入式框架中的函数 我想知道我的网页中所有的div的id,怎么做??? 如何实现在输入框中输入数据,后面的checkbox自动打勾 有关select选择后执行函数来返回值的问题
给你参考一下。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
<!-- #div1 {
position: relative;
height: 25px;
width: 60px;
background-color: #FFD5AA;
} #div2 {
position: absolute;
top: 25px;
left: 0px;
background-color: #B5FFB5;
}
-->
</style>
<script type="text/javascript">
<!--
var stop = null;
window.onload = function(){
$("div1").onmouseover = mouseOver;
function mouseOver(e){
e = e || window.event;
if (stop) {
clearTimeout(stop);
}
$("div2").style.display = "block";
expand($("div2"), "+", 140, "block");
}
$("div1").onmouseout = $("div2").onmouseout = function(e){
e = e || window.event;
var elFrom = e.fromElement || e.target;
var elTo = e.toElement || e.relatedTarget;
if ((elFrom.id == "div1" && elTo.id == "div2") || (elFrom.id == "div2" && elTo.id == "div1")) {
return;
}
if (stop) {
clearTimeout(stop);
}
expand($("div2"), "-", 0, "none");
}
}
function expand(o, fuhao, wh, dis){
if (parseInt(o.style.height) == wh || parseInt(o.style.height) == wh) {
clearTimeout(stop);
o.style.display = dis;
stop = null;
return;
}
eval("var th = parseInt(o.style.height)" + fuhao + "5");
eval("var tw = parseInt(o.style.height)" + fuhao + "5");
o.style.height = th + "px";
o.style.width = tw + "px";
stop = setTimeout(function(){
expand(o, fuhao, wh, dis)
}, 10);
}
function $(oid){
return document.getElementById(oid);
}
//-->
</script>
</head>
<body>
<div id="div1">
<div id="div2" style="width:0px;height:0px;display:none;">
</div>
</div>
</body>
</html>