我的代码在Firefox中完美运行,但我遇到了IE问题。当我执行时,我得到错误,程序没有正确执行。描述说clientX为null或不是对象。
var cursorLocation = new function(){
this.x = 0;
this.y = 0;
//This function is called onmousemove to update the stored position
this.update = function(e){
var w = window, b = document.body;
this.x = e.clientX + (w.scrollX || b.scrollLeft || b.parentNode.scrollLeft || 0);
this.y = e.clientY + (w.scrollY || b.scrollTop || b.parentNode.scrollTop || 0);
}} document.onmousemove=function(e){ cursorLocation.update(e); };
答案 0 :(得分:0)
你不应该在javascript中使用new function(){...}
。
有错误。
你应该做之类的事情:
var someFunction = function(){....};
var someVariable = new someFunction();