我怎么样能延迟2秒执行onmouseover事件。

wangyanyan 2007-06-01 09:22:58
我写了一个onmouseover事件,可我想当鼠标快速滑过的时候并不执行onmouseover事件,只有鼠标放上超过1秒再执行onmouseover事件应该怎么做?
...全文
1180 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
bsing 2007-06-01
  • 打赏
  • 举报
回复
private message
showrock 2007-06-01
  • 打赏
  • 举报
回复
PM就是发消息给他的意思,M我知道是MESSAGE,P是啥意思?
z6987590 2007-06-01
  • 打赏
  • 举报
回复
pm是什么?
bsing 2007-06-01
  • 打赏
  • 举报
回复
ps:可能不会一直跟中帖子,楼主如果有后续问题请pm.
lottery1821 2007-06-01
  • 打赏
  • 举报
回复
把setTimeout写在方法里面
bsing 2007-06-01
  • 打赏
  • 举报
回复
<!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>
<title> by Bsing </title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" type="text/css" rel="stylesheet">
</head>

<body>
<a href="javascript:;" onmouseover="initializeFun();setTimeout('waitFun()',1*1000);" onmouseout="exitFun();">test</a>
<div id="al"></div>
<script>
var tmp = true;
function waitFun()
{
if (tmp)
{
alert(tmp);
}
}
function initializeFun(){ tmp =true; document.getElementById("al").innerHTML = "true"; }
function exitFun(){ tmp = false; document.getElementById("al").innerHTML = "false"; }
</script>
</body>
</html>
wangyanyan 2007-06-01
  • 打赏
  • 举报
回复
所以settimeout肯定不行。
wangyanyan 2007-06-01
  • 打赏
  • 举报
回复
我用了settimeout可是为什么每隔2秒就执行一次呢?
babyrockxray 2007-06-01
  • 打赏
  • 举报
回复
setTimeOut
foyuan 2007-06-01
  • 打赏
  • 举报
回复
setTimeout(yourfunction,2*1000);

function yourfunction(){
alert();
}
guojh021 2007-06-01
  • 打赏
  • 举报
回复
学习!
foyuan 2007-06-01
  • 打赏
  • 举报
回复
晕 现在还没解决
<div onmouseover='ffff'/>
fff=function (){
var s=setTimeout(function(){
//do your work
clearTimeout(s);
},2*1000);
}
MaWenkun 2007-06-01
  • 打赏
  • 举报
回复
<img id="img1" style="width: 36px" src="Images/checked.png" onmouseover="a()" onmouseout="bb();" />
var timer = 3000;
var x;
function a()
{
x = setTimeout('aa()',timer);

}
function aa()
{
form1.img1.src = 'Images/unchecked.png';
window.clearInterval(x);
}
function bb()
{
window.clearTimeout(x);
form1.img1.src = "Images/checked.png";
}
绝代坏坏 2007-06-01
  • 打赏
  • 举报
回复
sleeping()
weizhuangzhi 2007-06-01
  • 打赏
  • 举报
回复
<SCRIPT LANGUAGE = "JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 10
StopTheClock()
StartTheTimer()
}

function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}

function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
// Here's where you put something useful that's
// supposed to happen after the allotted time.
// For example, you could display a message:
alert("You have just wasted 10 seconds of your life.")
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
//-->
</SCRIPT>
weizhuangzhi 2007-06-01
  • 打赏
  • 举报
回复
timerID = self.setTimeout('StartTheTimer()', delay);

运行后再clearTimeout(timerID)
impeller 2007-06-01
  • 打赏
  • 举报
回复
post message?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧