鼠标拖动图片

一、把下边的代码放到HTML的<body></body>之间:

<SCRIPT language=JavaScript>
drag = 0
move = 0
function init() {
window.document.onmousemove = mouseMove
window.document.onmousedown = mouseDown
window.document.onmouseup = mouseUp
window.document.ondragstart = mouseStop
}
function mouseDown() {
if (drag) {
clickleft = window.event.x - parseInt(dragObj.style.left)
clicktop = window.event.y - parseInt(dragObj.style.top)
dragObj.style.zIndex += 1
move = 1
}
}
function mouseStop() {
window.event.returnValue = false
}
function mouseMove() {
if (move) {
dragObj.style.left = window.event.x - clickleft
dragObj.style.top = window.event.y - clicktop
}
}
function mouseUp() {
move = 0
}
</SCRIPT>
<div id="block1" onmouseout="drag=0" onmouseover="dragObj=block1; drag=1;" style="height: 90; left: 200; position: absolute; top: 200; width: 90">
<dd><img alt border="0" src=\'#\'" width="199" height="150"> </dd> </div>

二、将<body>标签改为<body onload="init()">即可


<TD width="263" height="550"><IFRAME id=Frame_Infomation name=Frame_Infomation src=\'#\'" frameBorder=2 width="100%" height="100%" scrolling="yes"></IFRAME></TD>


你可能感兴趣的:(图片,职场,休闲)