用鼠标拖动图片平移问题 <div id="img_layer" style="z-index:6" contentEditable=true> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没人解决我加了setCapture之后就可以了大家随便说说过两天结贴了 <body onmouseup="document.body.contentEditable=false">.... <img name="testimg" src="test.gif" width="300" height="200" onmousedown="document.body.contentEditable=true" >测试可行 img_layer.onmousedown=function(){ img_layer.setCapture(); ............. ............. 移动前初始化操作}document.body.onmousemove=function(){ ............. 移动过程 img_layer.releaseCapture();}document.body.onmouseup=function(){ ............. 移动结束处理} 楼上releaseCapture();放错地方了,应该是:img_layer.onmousedown=function(){ img_layer.setCapture(); ............. ............. 移动前初始化操作}document.body.onmousemove=function(){ ............. 移动过程}document.body.onmouseup=function(){ ............. 移动结束处理 img_layer.releaseCapture();} <html><head><style type="text/css">.drag{position:relative;cursor:hand}</style><script language="javascript">var dragapproved = false;var z,x,yfunction move(){ if(event.button==1&&dragapproved) { z.style.pixelLeft=temp1+event.clientX-x z.style.pixelTop = temp2+event.clientY-y return false; }}function drags(){ if(!document.all) return if(event.srcElement.className=="drag") { dragapproved = true z=event.srcElement; temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.onmousemove=move }}document.onmousedown=dragsdocument.onmouseup=new Function("dragapproved=false")</script></head><body><img src="Date/c.jpg" class="drag" border="0" alt="Image"></body></html> js中的instanceof操作符的原理是什么? 关于Javasrcirpt处理byte[]问题 web 打印 用JavaScript在iframe中打开一个网页? 通过javascript取datagrid中控件值 怎么在form的action之后做某事 showModalDialog遇到的问题,各位帮我看看! 如何将javascript中的数组值传给jsp? 请赐教!一个判断日期时间函数 document.write (7*6.6) 输出的结果怎么是46.199999999999996 ?? 接着求教,如何为动态创建的元素添加右键菜单 百分求助,保持滚动条位置的问题。在线等!!
我加了setCapture之后就可以了
大家随便说说
过两天结贴了
....
<img name="testimg" src="test.gif" width="300" height="200" onmousedown="document.body.contentEditable=true" >
测试可行
img_layer.setCapture();
.............
.............
移动前初始化操作
}document.body.onmousemove=function(){
.............
移动过程
img_layer.releaseCapture();
}
document.body.onmouseup=function(){
.............
移动结束处理
}
应该是:
img_layer.onmousedown=function(){
img_layer.setCapture();
.............
.............
移动前初始化操作
}document.body.onmousemove=function(){
.............
移动过程
}
document.body.onmouseup=function(){
.............
移动结束处理
img_layer.releaseCapture();}
<head>
<style type="text/css">
.drag{position:relative;cursor:hand}
</style>
<script language="javascript">
var dragapproved = false;
var z,x,y
function move()
{
if(event.button==1&&dragapproved)
{
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop = temp2+event.clientY-y
return false;
}
}
function drags()
{
if(!document.all)
return
if(event.srcElement.className=="drag")
{
dragapproved = true
z=event.srcElement;
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}
}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
</script>
</head>
<body>
<img src="Date/c.jpg" class="drag" border="0" alt="Image">
</body>
</html>