我这里有个table表格,我想在mouse移动到表格项的时候弹出一个菜单,但是为了避免弹出的太快影响到server。 我想延时两秒,做法如下
//for popup windowvar popup_timeout = null;
function popup_mouse_over(event){
clearTimeout(popup_timeout); popup_timeout = setTimeout(function(){showInfoBox(event);},2000);
}function popup_mouse_out(event){ clearTimeout(popup_timeout);
}
这两个函数分别赋给对应的 onmouseover和onmouseout, 在没加这个延时的时候一切工作正常, 加了之后,就告诉我
event对象不存在。 btw:我要在showinfoBox里用event来定位弹出菜单的位置。。请问该怎么做,谢谢
//for popup windowvar popup_timeout = null;
function popup_mouse_over(event){
clearTimeout(popup_timeout); popup_timeout = setTimeout(function(){showInfoBox(event);},2000);
}function popup_mouse_out(event){ clearTimeout(popup_timeout);
}
这两个函数分别赋给对应的 onmouseover和onmouseout, 在没加这个延时的时候一切工作正常, 加了之后,就告诉我
event对象不存在。 btw:我要在showinfoBox里用event来定位弹出菜单的位置。。请问该怎么做,谢谢
popup_timeout = setTimeout(function(e){showInfoBox(e);}(event),2000); 试试
var popup_timeout = null;
function popup_mouse_over(event){
clearTimeout(popup_timeout);
popup_timeout = setTimeout((
function(obj){
return function(){
showInfoBox(obj);
}
}
)(event),2000);
}function popup_mouse_out(event)
{
clearTimeout(popup_timeout);
}
clearTimeout(popup_timeout);
function test(){
(function tt(e){
showInfoBox(e);
})(event)
}
popup_timeout = setTimeout(test,2000);
}
现在应该可以了
function popup_mouse_over(event){
clearTimeout(popup_timeout);
function test(){
(function(e){
showInfoBox(e);
})(event)
}
popup_timeout = setTimeout(test,2000);
}
谢谢,这个方法在firefox下可以用,但是ie6里用不成阿
function popup_mouse_over(mse){
clearTimeout(popup_timeout);
function test(){
(function(e){
showInfoBox(e);
})(mse)
}
popup_timeout = setTimeout(test,2000);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function func1(mse){
function func2(){
(function(e){
tt(e);
})(mse)
}
setTimeout(func2,2000);
}
function tt(e){
alert(e);
}
</script>
</head><body>
<input type="button" value="Display timed alertbox!" onClick="func1(event)">
</body>
</html>