为什么代码没问题 可是图片却不能飘动

A609863558 2017-09-25 12:08:09
<!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>
</head>

<body>
<body>
<div id="div1" style="position:absolute;z-index:10;" onmouseover="clearmove()" onmouseout="clock()">
<img src="9[F_BFZ_JS%R$DPY$L@BSM1.jpg" />
<p align="right"><a href="javascript:closeme()">关闭</a></p>
</div>
<table width="300" height="300">
<tr>
<td></td>
</tr>
</table>
</body>
<script language="javascript">
var curX=20;
var curY=20;
var step=5;
var dx=1;
var dy=1;
function move()
{
var d=document.getElementById("div1");
curX=curX+step*dx;
curY=curY+step*dy;
d.style.left=curX;
d.style.top=curY;
var w=document.body.clientWidth-280;
var h=document.body.clientHeight-200;
if(curX>=w){curX=w;dx=-dx;}
if(curX<=0){curX=0;dx=-dx;}
if(curY>=h){curY=h;dy=-dy;}
if(curY<=0){curY=0;dy=-dy;}
document.title="curX="+curX+",curY="+curY+",w="+w+",h="+h;
}
var time=null;
function clock()
{
move();
time=setTimeout("clock()",100);
}
function clearmove()
{
clearTimeout(time);
}
function closeme()
{
document.getElementById("div1").style.display="none";
}
</script>
</body>
</html>
...全文
133 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
枫舞蝶刺 2017-09-25
  • 打赏
  • 举报
回复
move方法中 d.style.left=curX+"px"; d.style.top=curY+"px";
墨笙弘一 2017-09-25
  • 打赏
  • 举报
回复
打开开发者工具进行调试 看看效果 和执行流程

51,412

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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