解决方案 »
- window.opener.document 为空或不是对象
- javascript如果判断keyup事件前后value值是否有变化
- EasyUI新组件-拖拽类EasyDragDrop,弹出层基类EasyLayer,遮罩类EasyMask,Popup类
- 千古奇遇 让人相当费解
- 以下源代码在IE正常但火狐不兼容望高手帮忙改正
- 关于js的调用问题
- 如何用javascript创建类似session的东西
- 请问如何在javascript中删除一个表格,(使用dhtml)
- 关于打印..
- 如何在用javascript:history.back();返回后自动刷新返回后的页面?谢谢!
- 如何解决几个动作延迟执行(提问可能不太准确...)?
- 用过 dhtmlx 中的 dhtmlGrid 的请进
那么你就需要这么调用 VAR TEST=NEW dragtest();
document.onmouseover = dragtest.moveit();
否则请将调用函数的那个()带上还有那个参数E
你只声明了THIS.moveit()没有THIS.moveit
document.onmouseover = this.moveit();
document.onmousemove=???
var dragtestobj = new dragtest();
dragtestobj.initialize();
我是这样实例化对象地。我并没有要直接调用this.moveit方法!
而是打算把该方法赋值给 document.onmouseover 让这个事件来调用,触发的时候自动调用!
function dragtest() {
}
dragtest.prototype.initialize = function() {
document.onmousedown = this.drag(e);//考虑下这个E怎么传
document.onmouseup = function() {
alert("onmouseup");
}
}
dragtest.prototype.drag = function(e) {
alert("drag");
document.onmouseover = this.moveit(e);
}
dragtest.prototype.moveit = function(e) {
alert("moveit");
}
}
dragtest.prototype.initialize = function() {
document.onmousedown = this.drag;
document.onmouseover = this.moveit;
document.onmouseup = function() {
alert("onmouseup");
}
}
dragtest.prototype.drag = function(e) {
alert("drag");
}
dragtest.prototype.moveit = function(e) {
alert("moveit");
}
我将document.onmouseover = this.moveit; 移到dragtest.prototype.initialize中就能正确找到moveit方法,为什么放在dragtest.prototype.drag中就出错,说尚未实现
}
dragtest.prototype.initialize = function() {
document.onmousedown = this.drag;
document.onmouseup = function() {
alert("onmouseup");
}
}
dragtest.prototype.drag = function() {
alert("drag");
document.onmouseover = this.moveit;
}
dragtest.prototype.moveit = function() {
alert("moveit");
}
var dragtestobj = new dragtest();
dragtestobj.initialize();实例化对象并调用initialize时候,事件对象是实例对象dragtestobjdragtest.prototype.initialize = function() {
document.onmousedown = this.drag;
document.onmouseup = function() {
alert("onmouseup");
}
}所以此处document.onmousedown = this.drag;,this指的是 dragtestobj而当鼠标移动触发document.onmousedown事件是的事件源是document
dragtest.prototype.drag = function() {
alert("drag");
document.onmouseover = this.moveit;
}所以此处document.onmouseover = this.moveit;,this指的是 document,故document对象是没有moveit方法的。