HTML js特效问题

pygnzj pygnzj 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<script type="text/javascript">
document.onmousemove=picfloat;
function inicial() {
document.getElementById("pic").style.left="0px";
document.getElementById("pic").style.top="0px";
}
var left, top;
var speed=5;
function picfloat(event) {
var event=window.event||event;
while(1) {
left=document.getElementById("pic").style.left;
top=document.getElementById("pic").style.top;
t=setTimeout(follow(left,top),1);
}
}
function follow(left,top) {
if(parseInt(left)<=parseInt(event.clientX)) {
document.getElementById("pic").style.left=(parseInt(left)+speed)+"px";
} else {
document.getElementById("pic").style.left=(parseInt(left)-speed)+"px";
}
if(parseInt(top)<=parseInt(event.clientY)) {
document.getElementById("pic").style.top=(parseInt(top)+speed)+"px";
} else {
document.getElementById("pic").style.top=(parseInt(top)-speed)+"px";
}
}
</script>
<style type="text/css">
#pic {
position:absolute;
}
</style>
</head>

<body onload="inicial()">

<div>
<img src="images/xmsx.gif" onmouseover="document.location.href='Apr1st.html'" id="pic"/>
</div>

</body>
</html>


这段代码 当鼠标不移动的时候 图片移动的就非常慢 应该如何解决呢
...全文
评论 2
收藏 已收藏
分享
返回顶部
pygnzj
C# 111,129 成员 642,540 内容