大家有遇到这样的问题吗?chorome和IE产生的滑动条overflow:auto无法捕获mouseup事件,火狐可以?有没有解决方法?
<div id="drag" style="overflow:auto; height:10px;position:relative;width:100%">
54465456456455446545645645544654564564554465456456455446545645645544654564564554465456456455446545645645544654564564554465456456455446545645645
</div><script>
$(document).ready(function(){
var orj=document.getElementById('drag');
new Drag(orj);
})
var Drag=function(a) {
this.target = a;
this.pos = [];
this.isDrag = !1;
if(this.target) {
this.addEvent(this.target,'mousedown',this.bind(this,this.start));
this.addEvent(document,'mouseup',this.bind(this,this.end));
this.addEvent(this.target,'mouseup',this.bind(this,this.bend));
his.addEvent(document,'mousemove',this.bind(this,this.move));
}
}
Drag.prototype = {
start: function(e) {
},move: function(e) {
}end: function(e) {
console.log("ds")
},bend:function(e){
console.log("pp")
},bind:function(o,fn){
return function(e) {
var at=checkBro();
if(at!=3){
var ev = e || window.event;
ev.pageX = e.pageX || ev.clientX;
ev.pageY = e.pageY || ev.clientY;
ev.stop = e.preventDefault? function() {
e.preventDefault();
e.stopPropagation();
} : function() {
ev.cancelBubble = true;
ev.returnValue = false;
}
}else{
e.stop = e.preventDefault? function() {
e.preventDefault();
e.stopPropagation();
} : function() {
e.cancelBubble = true;
e.returnValue = false;
}
}
fn.call(o,e);
}
},
addEvent:function(o,type,fn){
o.attachEvent?o.attachEvent('on'+type,fn):o.addEventListener(type,fn,false);
}
}
function checkBro(){
var userAgent = navigator.userAgent.toLowerCase();
if(navigator.userAgent.indexOf("MSIE")>0){
return 0;
}else if(userAgent.indexOf("chrome")>0){
return 0;
}else if(navigator.productSub.slice(0,4)<2011){
return 3;
}else{
return 1;
}
}
</script>
<div id="drag" style="overflow:auto; height:10px;position:relative;width:100%">
54465456456455446545645645544654564564554465456456455446545645645544654564564554465456456455446545645645544654564564554465456456455446545645645
</div><script>
$(document).ready(function(){
var orj=document.getElementById('drag');
new Drag(orj);
})
var Drag=function(a) {
this.target = a;
this.pos = [];
this.isDrag = !1;
if(this.target) {
this.addEvent(this.target,'mousedown',this.bind(this,this.start));
this.addEvent(document,'mouseup',this.bind(this,this.end));
this.addEvent(this.target,'mouseup',this.bind(this,this.bend));
his.addEvent(document,'mousemove',this.bind(this,this.move));
}
}
Drag.prototype = {
start: function(e) {
},move: function(e) {
}end: function(e) {
console.log("ds")
},bend:function(e){
console.log("pp")
},bind:function(o,fn){
return function(e) {
var at=checkBro();
if(at!=3){
var ev = e || window.event;
ev.pageX = e.pageX || ev.clientX;
ev.pageY = e.pageY || ev.clientY;
ev.stop = e.preventDefault? function() {
e.preventDefault();
e.stopPropagation();
} : function() {
ev.cancelBubble = true;
ev.returnValue = false;
}
}else{
e.stop = e.preventDefault? function() {
e.preventDefault();
e.stopPropagation();
} : function() {
e.cancelBubble = true;
e.returnValue = false;
}
}
fn.call(o,e);
}
},
addEvent:function(o,type,fn){
o.attachEvent?o.attachEvent('on'+type,fn):o.addEventListener(type,fn,false);
}
}
function checkBro(){
var userAgent = navigator.userAgent.toLowerCase();
if(navigator.userAgent.indexOf("MSIE")>0){
return 0;
}else if(userAgent.indexOf("chrome")>0){
return 0;
}else if(navigator.productSub.slice(0,4)<2011){
return 3;
}else{
return 1;
}
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货