关于DIV拖动时鼠标形状 document.body.style.cursor="move" ; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><body><div id="div1" style="LEFT: 0px; WIDTH: 356px; CURSOR: move; POSITION: absolute; TOP: 0px; HEIGHT: 284px; BACKGROUND-COLOR: silver;BACKGROUND-IMAGE: url(http://zi.csdn.net/dc468_60.gif)" language="javascript" onmousedown="down()" onmousemove="move()" onmouseup="up()"></div><script>var isdown = falsevar beginx,beginyfunction down() {isdown = true;}function move() { if (isdown) { var endx = event.clientX; var endy = event.clientY; div1.style.left = parseInt( div1.style.left ) + endx-beginx; div1.style.top = parseInt( div1.style.top ) + endy-beginy; } beginx = event.clientX; beginy = event.clientY;}function up() {isdown = false;}document.body.onmousemove = movedocument.body.onmouseup = up</script></body></html> 楼上老兄没有解决我的问题,我的主要问题是:拖动前鼠标为move形状,拖动时鼠标形状变了,怎么让它不变。 在我这里不变的.你的鼠标是不是变成漏斗形?如果是的话,把图片预加载一下( var theImg = new Image( url ) )就可以了 function move() {if (isdown){divid.style.cursor="hand";endx = event.clientX;endy = event.clientY;div1.style.left = endx-beginx;div1.style.top = endy-beginy;}} 层的代码改为如下:<div id="div1" style="LEFT: 0px; WIDTH: 356px; CURSOR: move; POSITION: absolute; TOP: 0px; HEIGHT: 284px;"language="javascript" onmousedown="down()" onmousemove="move()" onmouseup="up()"><div style="WIDTH: 100%; CURSOR: move; POSITION: absolute; HEIGHT: 100%; z-index:2;BACKGROUND-IMAGE: url(file:///E:\My Documents\My Pictures\样品.jpg)"></div></div> xishanlang2001(西山狼2000) ,怎么预加载?liuxiaoyi666(MSMVP 小猪妹荣誉马甲之八卦兔子)的办法不行。cuixiping(无心) 的办法可以,就是在拖动的DIV里嵌一个DIV,不过我想知道为什么,能说一下吗? 我的问题是出现个WEINDOWS系统的禁止拖拽的光标是怎么回事情, 请问一个标准的构造函数内,是不是最好只有对象和属性?没有其他变量或函数语句什么的啊? JS Math.PI递增问题 goahead+matrixssl制作webserver 怎样将字符串转成浮点数? 什么是JavaScript跨域操作啊? select的已选代码是什么啊? js的一个白痴取值问题。。。。 关于播放器问题麻烦有经验的人来指教我一下---小弟在这里谢谢了~ javascript中如何定时更改网页背景图片? 考一考:一个很常见的问题 请教: 当鼠标移至链接时, 如何显示该链接的预览(有答案加分结帐) 再问正则问题
<body>
<div id="div1" style="LEFT: 0px; WIDTH: 356px; CURSOR: move; POSITION: absolute; TOP: 0px; HEIGHT: 284px; BACKGROUND-COLOR: silver;BACKGROUND-IMAGE: url(http://zi.csdn.net/dc468_60.gif)"
language="javascript" onmousedown="down()" onmousemove="move()" onmouseup="up()"></div>
<script>
var isdown = false
var beginx,beginy
function down()
{
isdown = true;
}function move()
{
if (isdown)
{
var endx = event.clientX;
var endy = event.clientY;
div1.style.left = parseInt( div1.style.left ) + endx-beginx;
div1.style.top = parseInt( div1.style.top ) + endy-beginy;
}
beginx = event.clientX;
beginy = event.clientY;}function up()
{
isdown = false;
}
document.body.onmousemove = move
document.body.onmouseup = up
</script>
</body>
</html>
你的鼠标是不是变成漏斗形?如果是的话,把图片预加载一下( var theImg = new Image( url ) )就可以了
{
if (isdown)
{
divid.style.cursor="hand";
endx = event.clientX;
endy = event.clientY;
div1.style.left = endx-beginx;
div1.style.top = endy-beginy;
}
}
<div id="div1" style="LEFT: 0px; WIDTH: 356px; CURSOR: move; POSITION: absolute; TOP: 0px; HEIGHT: 284px;"
language="javascript" onmousedown="down()" onmousemove="move()" onmouseup="up()"><div style="WIDTH: 100%; CURSOR: move; POSITION: absolute; HEIGHT: 100%; z-index:2;BACKGROUND-IMAGE: url(file:///E:\My Documents\My Pictures\样品.jpg)"></div></div>