<!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">
<!--
window.onload = function(){
$("div1").onmouseover = function(e){
if ($("div2").style.width != "0px")
return;
$("div2").style.display = "block";
expand($("div2"), "+", 140, "block");
}
$("div1").onmouseout = $("div2").onmouseout = function(e){
e = e || window.event;
var elTo = e.toElement || e.relatedTarget;
if (elTo.id == "div1" || elTo.id == "div2") {
return;
}
if ($("div2").style.width != "140px")
return;
expand($("div2"), "-", 0, "none");
}
}
function expand(o, fuhao, wh, dis){
eval("var th = parseInt(o.style.height)" + fuhao + "5");
eval("var tw = parseInt(o.style.width)" + fuhao + "5");
o.style.height = th + "px";
o.style.width = tw + "px";
stop = setTimeout(function(){
expand(o, fuhao, wh, dis)
}, 10);
if (th == wh || tw == wh) {
clearTimeout(stop);
o.style.display = dis;
}
}
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>
<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">
<!--
window.onload = function(){
$("div1").onmouseover = function(e){
if ($("div2").style.width != "0px")
return;
$("div2").style.display = "block";
expand($("div2"), "+", 140, "block");
}
$("div1").onmouseout = $("div2").onmouseout = function(e){
e = e || window.event;
var elTo = e.toElement || e.relatedTarget;
if (elTo.id == "div1" || elTo.id == "div2") {
return;
}
if ($("div2").style.width != "140px")
return;
expand($("div2"), "-", 0, "none");
}
}
function expand(o, fuhao, wh, dis){
eval("var th = parseInt(o.style.height)" + fuhao + "5");
eval("var tw = parseInt(o.style.width)" + fuhao + "5");
o.style.height = th + "px";
o.style.width = tw + "px";
stop = setTimeout(function(){
expand(o, fuhao, wh, dis)
}, 10);
if (th == wh || tw == wh) {
clearTimeout(stop);
o.style.display = dis;
}
}
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>
解决方案 »
- jquery easy ui 中的datagrid Demo 放到VS IDE中显示不了数据
- 大家帮我看看这个树的JSON数据有什么不对,我找了半天了,谢谢大家,100分送找对的人.在线等
- 又是未定义错误!!!
- [HELP] JS 正则表达式 只有 向前查找,向后查找 咋整?!
- 时间js
- 请教一下大伙 网易这个音乐播放器是怎么做的呢
- 求高手看看JS循环代码。
- 一个简单的js问题
- 急:请问一个input用javascript如何定义其readonly属性。
- 请教document.write("<marquee>neirong</marquee>")定义的对象的定位问题
- 字串的修改?
- 请告诉我几个午休时间可以学习网站建设的地址。
不过频繁的移动还是有问题呀.
等脑袋清醒的时候再改改吧.<!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">
<!--
window.onload = function(){
$("div1").onmouseover = mouseOver;
function mouseOver(e){
e = e || window.event;
if ($("div2").style.width != "0px") {
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;
}
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;
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>
<!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">
<!--
//=======ff的contains扩展
if(typeof(HTMLElement)!="undefined")HTMLElement.prototype.contains=function(o){
if(o==this)return true;
while(o=o.parentNode)if(o==this)return true;
return false;
}
window.onload=function(){
$("div1").onmouseover=function(){
if ($("div2").style.width != "0px") return;
$("div2").style.display = "block";
expand($("div2"),"+",140,"block");
}
$("div1").onmouseout=function(e){//---------------
e=e||event;//---------------
var toObj=e.toElement||e.relatedTarget;//---------------
if(this.contains(toObj))return;//---------------
if ($("div2").style.width != "140px") return;
expand($("div2"),"-",0,"none");
}
}
function expand(o,fuhao,wh,dis){
eval("var th = parseInt(o.style.height)"+fuhao+"5");
eval("var tw = parseInt(o.style.width)"+fuhao+"5");
o.style.height = th+"px";
o.style.width = tw+"px";
stop = setTimeout(function(){ expand(o,fuhao,wh,dis) },10);
if (th == wh || tw == wh){
clearTimeout(stop);
o.style.display = dis;
}
}
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>
<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>
div1 out的时候开始计时 yt = setTimeout(expand, 50);
div2 over的时候如果有div1的计时器就清除掉, 不让他执行 expand, clearTimeout(yt);代码
<!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">
<!--
window.onload=function(){
var yt = null;
$("div1").onmouseover=function(){
if(yt) clearTimeout(yt);
if ($("div2").style.width != "0px") return;
$("div2").style.display = "block";
expand($("div2"),"+",140,"block");
}
$("div1").onmouseout=function(){
if ($("div2").style.width != "140px") return;
if(yt) clearTimeout(yt);
yt = setTimeout(function(){
expand($("div2"),"-",0,"none")
}, 50);
}
$("div2").onmouseover=function(){
clearTimeout(yt);
}
$("div2").onmouseout=function(){
if(yt) clearTimeout(yt);
yt = setTimeout(function(){
expand($("div2"),"-",0,"none")
}, 50);
}
}
function expand(o,fuhao,wh,dis){
eval("var th = parseInt(o.style.height)"+fuhao+"5");
eval("var tw = parseInt(o.style.width)"+fuhao+"5");
o.style.height = th+"px";
o.style.width = tw+"px";
stop = setTimeout(function(){ expand(o,fuhao,wh,dis) },10);
if (th == wh || tw == wh){
clearTimeout(stop);
o.style.display = dis;
}
}
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>
<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">
<!--
window.onload=function(){
var yt = null;
$("div1").onmouseover=function(){
if(yt) clearTimeout(yt);
if ($("div2").style.width != "0px") return;
$("div2").style.display = "block";
expand($("div2"),"+",140,"block");
}
$("div1").onmouseout=function(){
if ($("div2").style.width != "140px") return;
if(yt) clearTimeout(yt);
yt = setTimeout(function(){
expand($("div2"),"-",0,"none")
}, 50);
}
$("div2").onmouseover=function(){
clearTimeout(yt);
}
$("div2").onmouseout=function(){
if(yt) clearTimeout(yt);
yt = setTimeout(function(){
expand($("div2"),"-",0,"none")
}, 50);
}
}
function expand(o,fuhao,wh,dis){
eval("var th = parseInt(o.style.height)"+fuhao+"5");
eval("var tw = parseInt(o.style.width)"+fuhao+"5");
o.style.height = th+"px";
o.style.width = tw+"px";
stop = setTimeout(function(){ expand(o,fuhao,wh,dis) },10);
if (th == wh || tw == wh){
clearTimeout(stop);
o.style.display = dis;
}
}
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>
楼上的可以!
将鼠标移动到div1中,
并在div2放大的过程中。
迅速将鼠标移出div1,
div2仍然被显示出来了。
......
<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">
<!--
window.onload = function(){
var t, div1 = $('div1'), div2=$('div2'), maxw = 140;
div2.t = null;
div1.onmouseover = function(){
if(t) clearTimeout(t);
status = div2.t;
if(div2.offsetWidth >= maxw) return;
div2.style.display = 'block';
clearInterval(div2.t);
div2.t = setInterval(function(){ expand(div2, 1, maxw);}, 10);
} div1.onmouseout = function(){
if(div2.offsetWidth < maxw){
clearInterval(div2.t);
div2.t = setInterval(function(){ expand(div2, 0)}, 10);
}else{
t = setTimeout(function(){
div2.t = setInterval(function(){ expand(div2, 0)}, 10);
}, 1);
}
}
} function expand(obj, s, w){
if(s){
if(obj.offsetWidth>=w){
clearTimeout(obj.t);
}else{
obj.style.width = obj.offsetWidth + 5 +'px';
obj.style.height = obj.offsetHeight + 5 +'px';
}
}else{
if(obj.offsetWidth<=0){
clearInterval(obj.t);
obj.style.display = 'none';
}else{
obj.style.width = obj.offsetWidth - 5 +'px';
obj.style.height = obj.offsetHeight - 5 +'px';
}
}
} 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>
不好鼠标快速的在div1中移入移出几次后,
div2就再也不动了。