注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 科普系列之-使用Windows的..
 帮助

鼠标拖动图片


2006-04-29 15:22:02
 标签:图片   [推送到技术圈]

一、把下边的代码放到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="tn583182B.jpg" width="199" height="150"> </dd> </div>

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


<TD width="263" height="550"><IFRAME id=Frame_Infomation name=Frame_Infomation src="BlankColor.jsp" frameBorder=2 width="100%" height="100%" scrolling="yes"></IFRAME></TD>






    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: