javascript实现浏览器界面图标随意拖拽

来源:互联网 发布:厘米秀刷花软件 编辑:程序博客网 时间:2024/04/29 21:56

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>随意拖动图片</title></head><body onLoad="remove()"><div id="div1" onMouseOver="dragimages=div1;drag=1;"style="height:77px;left:10px;position:absolute;top:10px;width:90px"><img name="img1" alt="" border="0" src="http://www.codefans.net/images/logo.gif" style="cursor:pointer "></div><p><script language="javascript">drag = 0;move = 0;function mousedown(){if(drag){X1 = window.event.x - parseInt(dragimages.style.left);Y1 = window.event.y - parseInt(dragimages.style.top);dragimages.style.Index += 1;move = 1;}}function mouseStop(){window.event.returnValue = false;}function mousemove(){if (move){dragimages.style.left = window.event.x - X1;dragimages.style.top = window.event.y - Y1;}}function mouseup(){move = 0;}function remove(){document.all.div1.onmousemove = mousemove;document.all.div1.onmousedown = mousedown;document.all.div1.onmouseup = mouseup;document.all.div1.ondragstart  = mouseStop;}</script></body></html>


0 0