关于DIV拖动时鼠标形状

lookfeng 2006-07-14 10:27:43
DIV设置了鼠标形状为Move, 当DIV没有设置背景图片时,拖动DIV时鼠标正常,
但设置背景图片后,拖动DIV时鼠标不是Move形状了。知道为什么吗?

代码如下:


<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script id="clientEventHandlersJS" language="javascript">
<!--
var isdown = false;
var beginx,beginy,endx,endy;

function down()
{
isdown = true;
beginx = event.clientX;
beginy = event.clientY;
}

function move()
{
if (isdown)
{
endx = event.clientX;
endy = event.clientY;
div1.style.left = endx-beginx;
div1.style.top = endy-beginy;
}
}

function up()
{
isdown = false;
}

//-->
</script>
</head>
<body ms_positioning="GridLayout">
<div id="div1" style="LEFT: 0px; WIDTH: 356px; CURSOR: move; POSITION: absolute; TOP: 0px; HEIGHT: 284px; BACKGROUND-COLOR: silver;BACKGROUND-IMAGE: url(file:///E:\My Documents\My Pictures\样品.jpg)"
language="javascript" onmousedown="down()" onmousemove="move()" onmouseup="up()"></div>

</body>
</html>
...全文
526 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tfp 2006-11-12
  • 打赏
  • 举报
回复
FF 下这个不动弹
tfp 2006-11-11
  • 打赏
  • 举报
回复
我的问题是出现个WEINDOWS系统的禁止拖拽的光标

是怎么回事情,

wideroad 2006-07-19
  • 打赏
  • 举报
回复
记载完之后重新设置一下鼠标的图片
lookfeng 2006-07-19
  • 打赏
  • 举报
回复
欢迎继续讨论!
xishanlang2001 2006-07-14
  • 打赏
  • 举报
回复
<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 = 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>
xishanlang2001 2006-07-14
  • 打赏
  • 举报
回复
抱歉,没看清题目
xishanlang2001 2006-07-14
  • 打赏
  • 举报
回复
document.body.style.cursor="move" ;
lookfeng 2006-07-14
  • 打赏
  • 举报
回复
xishanlang2001(西山狼2000) ,怎么预加载?

liuxiaoyi666(MSMVP 小猪妹荣誉马甲之八卦兔子)的办法不行。

cuixiping(无心) 的办法可以,就是在拖动的DIV里嵌一个DIV,不过我想知道为什么,能说一下吗?
cuixiping 2006-07-14
  • 打赏
  • 举报
回复
层的代码改为如下:
<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>
  • 打赏
  • 举报
回复
function move()
{
if (isdown)
{
divid.style.cursor="hand";
endx = event.clientX;
endy = event.clientY;
div1.style.left = endx-beginx;
div1.style.top = endy-beginy;
}
}
xishanlang2001 2006-07-14
  • 打赏
  • 举报
回复
在我这里不变的.
你的鼠标是不是变成漏斗形?如果是的话,把图片预加载一下( var theImg = new Image( url ) )就可以了
lookfeng 2006-07-14
  • 打赏
  • 举报
回复
楼上老兄没有解决我的问题,我的主要问题是:拖动前鼠标为move形状,拖动时鼠标形状变了,怎么让它不变。

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧