我是在一个图片上的onmousedown上使用
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP)
但却无效, 在IE中使用的Obj.setCapture();才有效
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP)
但却无效, 在IE中使用的Obj.setCapture();才有效
解决方案 »
- Extjs 如何得到grid中某一列的值
- js 时间格式调试方面的错误,求分析解答
- 请问:类似百度的搜索框ajax功能应该如何实现
- 自己写的jquery自定义滚动条插件有问题,各位帮忙看看问题出在哪儿?
- 子页关闭如何刷新父页iframe
- 如何通过 javascript 禁用网页上的一个按钮??????急
- 为什么只有文件选择控件没有目录选择控件啊,要怎么实现目录选择呢?
- 如何把date类型转换为 string 类型??
- 为什么会出现"分页发生错误"的错误?
- .net 中json的一点问题
- frames[0].document.execCommand('InsertImage', false, src);成功插入后怎么把光标移到图片之后?
- 300分,怎样用JS为history.go(-1); 添加自己的方法?
{
var st = event.currentTarget.scrollTop + (event.detail * 12);
event.currentTarget.scrollTop = st < 0 ? 0 : st;
event.preventDefault();
}
if (document.body.addEventListener) {
var divs = document.getElementsByTagName('DIV');
for (var d in divs) {
if (divs[d].className && divs[d].className == 'tekstveld') {
try {
divs[d].addEventListener('DOMMouseScroll', scrollMe, false);
} catch (ex) {}
}
}
}
也使用了captureEvents<html>
<head>
<title> Drag Demo 1 </title>
<style type="text/css">
<!--
#drag{
width:100px;
height:20px;
background-color:#eee;
border:1px solid #333;
position:absolute;
top:30px;
left:200px;
text-align:center;
cursor:default;
}
//-->
</style>
<script type="text/javascript">
<!--
window.onload=function(){
drag(document.getElementById('drag'));
};function drag(o){
o.onmousedown=function(a){
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove=function(a){
if(!a)a=window.event;
if(!a.pageX)a.pageX=a.clientX;
if(!a.pageY)a.pageY=a.clientY;
var tx=a.pageX-x,ty=a.pageY-y;
o.style.left=tx;
o.style.top=ty;
}; d.onmouseup=function(){
if(o.releaseCapture)
o.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=null;
d.onmouseup=null;
};
};
}
//-->
</script>
</head><body>
<div id="drag">drag me<div>
</body>
</html>
图片可以拖动!
=============================
<html>
<head>
<title> Drag Demo 1 </title>
<style type="text/css">
<!--
#drag{
width:100px;
height:20px;
background-color:#eee;
border:1px solid #333;
position:absolute;
top:30px;
left:200px;
text-align:center;
cursor:default;
}
//-->
</style>
<script type="text/javascript">
<!--
window.onload=function(){
drag(document.getElementById('drag'));
};function drag(o){
o.onmousedown=function(a){
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove=function(a){
if(!a)a=window.event;
if(!a.pageX)a.pageX=a.clientX;
if(!a.pageY)a.pageY=a.clientY;
var tx=a.pageX-x,ty=a.pageY-y;
o.style.left=tx;
o.style.top=ty;
}; d.onmouseup=function(){
if(o.releaseCapture)
o.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=null;
d.onmouseup=null;
};
};
}
//-->
</script>
</head><body>
<img id="drag" src="http://community.csdn.net/logo/images/cc2e.jpg">
</body>
</html>