tryit_view.asp@filename=trydhtml_move
来自「W3Schools tutorial..web designing」· ASP@FILENAME=TRYDHTML_MOVE 代码 · 共 61 行
ASP@FILENAME=TRYDHTML_MOVE
61 行
<html>
<head>
<style>
img
{
position:absolute;
}
</style>
<script type="text/javascript">
document.onmousedown=coordinates;
document.onmouseup=mouseup;
function coordinates(e)
{
if (e == null) { e = window.event;}
var sender = (typeof( window.event ) != "undefined" ) ? e.srcElement : e.target;
if (sender.id=="moveMe")
{
mouseover=true;
pleft=parseInt(movMeId.style.left);
ptop=parseInt(movMeId.style.top);
xcoor=e.clientX;
ycoor=e.clientY;
document.onmousemove=moveImage;
return false;
}
else { return false; }
}
function moveImage(e)
{
if (e == null) { e = window.event;}
movMeId.style.left=pleft+e.clientX-xcoor+"px";
movMeId.style.top=ptop+e.clientY-ycoor+"px";
return false;
}
function mouseup(e)
{
document.onmousemove=null;
}
</script>
</head>
<body>
<img id="moveMe" src="smiley.gif" width="32" height="32" />
<p>Drag and drop the image</p>
<script type="text/javascript">
//The movable image
movMeId=document.getElementById("moveMe");
//image starting location
movMeId.style.top="75px";
movMeId.style.left="75px";
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?