
JS让图片移动的效果
html文件:<divid="div1"><pid="p">Areyouready?<br/><inputid="button"type="button"value="开...
html文件:
<div id="div1">
<p id="p">Are you ready?<br/>
<input id="button" type="button" value="开始游戏" onclick="showNewPage()"/>
</div>
<img id="image" src="ufo.png" width="240" height="140" />
</body>
</html>
html文件导入的js文件:
function showNewPage()
{
window.open('ufo大作战.html','_top');
}
var el=null;
var timer=null;
function moveIt()
{
if(parseInt(el.style.left)>(screen.width-50))
{
el.style.left=0;
}
el.style.left=parseInt(el.style.left)+6+"px";
el.style.top=200+(150*Math.sin(parseInt(el.style.left)))+"px";
timer=setTimeout("moveIt()",50);
}
function stop()
{
return false;
}
window.onload=function()
{
//禁止用户右键操作
document.oncontextmenu=stop;
el=document.getElementById("image");
moveIt();
}
用moveIt()函数来控制html文件中的图片移动 可是图片没动 展开
<div id="div1">
<p id="p">Are you ready?<br/>
<input id="button" type="button" value="开始游戏" onclick="showNewPage()"/>
</div>
<img id="image" src="ufo.png" width="240" height="140" />
</body>
</html>
html文件导入的js文件:
function showNewPage()
{
window.open('ufo大作战.html','_top');
}
var el=null;
var timer=null;
function moveIt()
{
if(parseInt(el.style.left)>(screen.width-50))
{
el.style.left=0;
}
el.style.left=parseInt(el.style.left)+6+"px";
el.style.top=200+(150*Math.sin(parseInt(el.style.left)))+"px";
timer=setTimeout("moveIt()",50);
}
function stop()
{
return false;
}
window.onload=function()
{
//禁止用户右键操作
document.oncontextmenu=stop;
el=document.getElementById("image");
moveIt();
}
用moveIt()函数来控制html文件中的图片移动 可是图片没动 展开
1个回答
展开全部
<img id="image" src="ufo.png" width="240" height="140"
style="position: absolute; left: 0px; top: 0px;" />
style="position: absolute; left: 0px; top: 0px;" />

2025-02-10 广告
可视化标签是广州晨控智能技术有限公司在物联网及自动识别领域的一项重要技术创新。通过先进的图形化界面设计,我们将复杂的数据信息转化为直观、易读的标签形式。这些标签不仅美观大方,更能够实时展示物品状态、库存数量、位置信息等关键数据。用户只需一眼...
点击进入详情页
本回答由晨控智能提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询