问题在下面注释的地方
各位大虾 指教下吧!~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Drag!!!</title>
</head>
<body>
<div id='ss' style="height:100px; width:100px; border:1px solid #000000"></div>
<script>
function $(Id){return document.getElementById(Id)};
function addListener(element,e,fn){ element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn)};
var BindAsEventListener = function(object, fun) {
return function(event) {
return fun.call(object, (event || window.event));
}
};
var Class = function(properties){
var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};
_class.prototype = properties;
return _class;
};
///////////////////////////////////////////////////////////////////////////////////////////上面都是公共函数 不需要看
var ff = new Class({
initialize:function(obj,options){
this._obj = obj;
//this._obj.style.position = "absolute"; //ie6下 加上这个就会有问题 无法给this._obj添加上onmousedown事件
addListener(this._obj,"mousedown",BindAsEventListener(this,this.Start));
},
Start:function(){
alert('a');
}
})
var gg = new ff($('ss'))
</script>
</body>
</html>
各位大虾 指教下吧!~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Drag!!!</title>
</head>
<body>
<div id='ss' style="height:100px; width:100px; border:1px solid #000000"></div>
<script>
function $(Id){return document.getElementById(Id)};
function addListener(element,e,fn){ element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn)};
var BindAsEventListener = function(object, fun) {
return function(event) {
return fun.call(object, (event || window.event));
}
};
var Class = function(properties){
var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};
_class.prototype = properties;
return _class;
};
///////////////////////////////////////////////////////////////////////////////////////////上面都是公共函数 不需要看
var ff = new Class({
initialize:function(obj,options){
this._obj = obj;
//this._obj.style.position = "absolute"; //ie6下 加上这个就会有问题 无法给this._obj添加上onmousedown事件
addListener(this._obj,"mousedown",BindAsEventListener(this,this.Start));
},
Start:function(){
alert('a');
}
})
var gg = new ff($('ss'))
</script>
</body>
</html>
实际上是绑定的,只要你拖边框就可知.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Drag!!!</title>
</head>
<body>
<div id='ss' style="height:100px; width:100px; border:1px solid #000000;left:10px;top:10px;"></div>
<script>
function $(Id){return document.getElementById(Id)};
function addListener(element,e,fn){ element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn)};
var BindAsEventListener = function(object, fun) {
return function(event) {
return fun.call(object, (event || window.event));
}
};
var Class = function(properties){
var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};
_class.prototype = properties;
return _class;
};
var ff = new Class({
initialize:function(obj,options){
this._obj = obj;
this._obj.style.position = "absolute";
this._obj.style.background = "red";
addListener(this._obj,"mousedown",BindAsEventListener(this,this.Start));
},
Start:function(){
alert('a');
}
})
var gg = new ff($('ss'))
</script>
</body>
</html>