javascript 错误:TypeError:window.attachEvent 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13190336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: TypeError: window.attachEvent is not a function
提问by subodh
I am using custome.js
,PIE.js
and jquery1_7_2.js
file in my jsp
我正在使用custome.js
,PIE.js
并jquery1_7_2.js
在我的文件中jsp
This is my custome.jsand nothing more.
这是我的custome.js,仅此而已。
jQuery(document).ready(function(){
jQuery(function() {
if (window.PIE) {
jQuery('#login-box, .sign-button, .new-user-btn, .grey-btn, .code-btn, #contact-email, #contact-email .continue, #contact-email .cancel').each(function() {
PIE.attach(this);
});
}
});
})
everything working fine in all browser. But in Firefox it is showing me this error
在所有浏览器中一切正常。但是在 Firefox 中,它向我显示了这个错误
Error: TypeError: PIE.attach is not a function
Source File: http://localhost:8080/MyApp/js/custom.js
Line: 6
Please guide me to solve this issue.
请指导我解决这个问题。
Edited:It showing me error in this line of PIE.js
编辑:它在这行PIE.js 中显示了错误
window.attachEvent("onunload",a);f.K.sa=function(b,c,d){b.attachEvent(c,d);this.ba(function(){b.detachEvent(c,d)})}})();f.Qa=new f.ea;f.K.sa(window,"onresize",function(){f.Qa.wa()});(function(){function a(){f.mb.wa()}f.mb=new f.ea;f.K.sa(window,"onscroll",a);f.Qa.ba(a)})();(function(){function a(){c=f.kb.md()}function b(){if(c){for(var d=0,e=c.length;d
window.attachEvent("onunload",a);fKsa=function(b,c,d){b.attachEvent(c,d);this.ba(function(){b.detachEvent(c,d)})} })();f.Qa=new f.ea;fKsa(window,"onresize",function(){f.Qa.wa()});(function(){function a(){f.mb. wa()}f.mb=new f.ea;fKsa(window,"onscroll",a);f.Qa.ba(a)})();(function(){function a(){c=f .kb.md()}function b(){if(c){for(var d=0,e=c.length;d
and custome.jsin this line
和custome.js在这一行
PIE.attach(this);
PIE.attach(this);
回答by Konstantin Dinev
When attaching events in order to make it cross browser perform the following:
当附加事件以使其跨浏览器执行以下操作时:
if (target.addEventListener) {
target.addEventListener(eventName, handlerName, false);
} else if (target.attachEvent) {
target.attachEvent("on" + eventName, handlerName);
} else {
target["on" + eventName] = handlerName;
}