<html>
<head>
<title>div test</title>
<script language="javascript">
var mouseX = 0;
var mouseY = 0;function divonmousemove(obj)
{
if ((Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4) && (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4))
obj.style.cursor='se-resize';
else if (Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4) obj.style.cursor='e-resize';
else if (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4) obj.style.cursor='s-resize';
else
obj.style.cursor='';
if (event.button==1)
{
obj.style.width = parseInt(obj.offsetWidth) + (event.x - mouseX);
mouseX = event.x;
obj.style.height = parseInt(obj.offsetHeight) + (event.y - mouseY);
mouseY = event.y;
}
}function divonmousedown(obj)
{
mouseX = event.x;
mouseY = event.y;
}function divonmouseup(obj)
{
mouseX = 0;
mouseY = 0;
}
</script>
</head>
<body>
<div onmousemove="divonmousemove(this);" onmouseleave="this.style.cursor='';"
onmousedown="divonmousedown(this);" onmouseup="divonmouseup(this);"
style="width:300;height:200;background:green" title="按下鼠标拖动大小">
按下鼠标拖动大小
<div>
</body>
</html>
<head>
<title>div test</title>
<script language="javascript">
var mouseX = 0;
var mouseY = 0;function divonmousemove(obj)
{
if ((Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4) && (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4))
obj.style.cursor='se-resize';
else if (Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4) obj.style.cursor='e-resize';
else if (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4) obj.style.cursor='s-resize';
else
obj.style.cursor='';
if (event.button==1)
{
obj.style.width = parseInt(obj.offsetWidth) + (event.x - mouseX);
mouseX = event.x;
obj.style.height = parseInt(obj.offsetHeight) + (event.y - mouseY);
mouseY = event.y;
}
}function divonmousedown(obj)
{
mouseX = event.x;
mouseY = event.y;
}function divonmouseup(obj)
{
mouseX = 0;
mouseY = 0;
}
</script>
</head>
<body>
<div onmousemove="divonmousemove(this);" onmouseleave="this.style.cursor='';"
onmousedown="divonmousedown(this);" onmouseup="divonmouseup(this);"
style="width:300;height:200;background:green" title="按下鼠标拖动大小">
按下鼠标拖动大小
<div>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货