图片移动不超出边界

[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>图片移动</TITLE>
<META http-equiv=keywords content=keyword1,keyword2,keyword3>
<META http-equiv=description content="this is my page">
<META http-equiv=content-type content="text/html; charset=UTF-8">
<SCRIPT language=javascript type=text/javascript>
var mouseObj=null;
var pX;
var pY;
document.οnmοusemοve=divMove;
document.οnmοuseup=divUp;
function m(c_Obj){

mouseObj=document.getElementById(c_Obj);
// mouseObj.style.position="absolute";
pX=mouseObj.style.pixelLeft-event.x;
pY=mouseObj.style.pixelTop-event.y;
}
function divMove(){
if(mouseObj){
mouseObj.style.cursor="move";
mouseObj.style.left=pX+event.x;
mouseObj.style.top=pY+event.y;
event.returnValue=false;
}
}
function divUp() {
if(mouseObj){
mouseObj.style.cursor="hand";
mouseObj=null;
}
}
</SCRIPT>

<STYLE>.div {
BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; OVERFLOW-Y: hidden; BACKGROUND: lightblue; OVERFLOW-X: hidden; PADDING-BOTTOM: 0px; BORDER-LEFT: #000 1px solid; WIDTH: 600px; BORDER-BOTTOM: #000 1px solid; HEIGHT: 800px
}
</STYLE>
</HEAD>
<BODY>
<DIV class=div id=imgDiv><IMG οnmοusedοwn="m('layer');" id=layer
style="POSITION: absolute;background:red;" src="11.jpg">
</DIV></BODY></HTML>
[/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值