下面是的代码在Win2000+IE6上通过验证<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head><body>
<table id="tabApplet" border="0" cellspacing="0" cellpadding="0"
style="position:absolute;left:0 ;top:0"
onMouseDown="tabApplet_MouseDown()"
onMouseUp="tabApplet_MouseUp()"
>
<tr>
<td bgcolor="#FFFF00" style="cursor:move">在这里按下拖动</td>
</tr>
<tr>
<td>
<applet></applet>
</td>
</tr>
</table><script language="JavaScript">
var iOldX, iOldY //按下鼠标
function tabApplet_MouseDown(){
if (event.button != 1) return
iOldX = event.x
iOldY = event.y
tabApplet.setCapture()
tabApplet.attachEvent("onmousemove", tabApplet_MouseMove)
}
//弹起鼠标
function tabApplet_MouseUp(){
tabApplet.detachEvent("onmousemove", tabApplet_MouseMove)
tabApplet.releaseCapture()
iOldX = null
iOldY = null
}
//移动鼠标
function tabApplet_MouseMove(){
var iNewX = event.x
var iNewY = event.y
var iOldLeft = parseInt(tabApplet.currentStyle.left)
var iOldTop = parseInt(tabApplet.currentStyle.top)
var iNewLeft = iOldLeft + (iNewX - iOldX)
var iNewTop = iOldTop + (iNewY - iOldY)
iOldX = iNewX
iOldY = iNewY
MoveTo(iNewLeft, iNewTop)
}
function MoveTo(iNewLeft, iNewTop){
//下面的代码是控制不让对象拖出Document的可视范围
var iX = document.body.clientWidth - tabApplet.clientWidth
var iY = document.body.clientHeight - tabApplet.clientHeight
if (iNewLeft < 0 || iX < 0){
iNewLeft = 0
}
else {
if (iNewLeft > iX) iNewLeft = iX
}
if (iNewTop < 0 || iY < 0){
iNewTop = 0
}
else {
if (iNewTop > iY) iNewTop = iY
}
tabApplet.style.left = iNewLeft
tabApplet.style.top = iNewTop
}</script></body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head><body>
<table id="tabApplet" border="0" cellspacing="0" cellpadding="0"
style="position:absolute;left:0 ;top:0"
onMouseDown="tabApplet_MouseDown()"
onMouseUp="tabApplet_MouseUp()"
>
<tr>
<td bgcolor="#FFFF00" style="cursor:move">在这里按下拖动</td>
</tr>
<tr>
<td>
<applet></applet>
</td>
</tr>
</table><script language="JavaScript">
var iOldX, iOldY //按下鼠标
function tabApplet_MouseDown(){
if (event.button != 1) return
iOldX = event.x
iOldY = event.y
tabApplet.setCapture()
tabApplet.attachEvent("onmousemove", tabApplet_MouseMove)
}
//弹起鼠标
function tabApplet_MouseUp(){
tabApplet.detachEvent("onmousemove", tabApplet_MouseMove)
tabApplet.releaseCapture()
iOldX = null
iOldY = null
}
//移动鼠标
function tabApplet_MouseMove(){
var iNewX = event.x
var iNewY = event.y
var iOldLeft = parseInt(tabApplet.currentStyle.left)
var iOldTop = parseInt(tabApplet.currentStyle.top)
var iNewLeft = iOldLeft + (iNewX - iOldX)
var iNewTop = iOldTop + (iNewY - iOldY)
iOldX = iNewX
iOldY = iNewY
MoveTo(iNewLeft, iNewTop)
}
function MoveTo(iNewLeft, iNewTop){
//下面的代码是控制不让对象拖出Document的可视范围
var iX = document.body.clientWidth - tabApplet.clientWidth
var iY = document.body.clientHeight - tabApplet.clientHeight
if (iNewLeft < 0 || iX < 0){
iNewLeft = 0
}
else {
if (iNewLeft > iX) iNewLeft = iX
}
if (iNewTop < 0 || iY < 0){
iNewTop = 0
}
else {
if (iNewTop > iY) iNewTop = iY
}
tabApplet.style.left = iNewLeft
tabApplet.style.top = iNewTop
}</script></body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货