最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: TypeError: window.attachEvent is not a function - Stack Overflow

programmeradmin2浏览0评论

I am using custome.js,PIE.js and jquery1_7_2.js file in my jsp

This is my custome.js and nothing more.

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

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

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

and custome.js in this line

PIE.attach(this);

I am using custome.js,PIE.js and jquery1_7_2.js file in my jsp

This is my custome.js and nothing more.

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

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

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

and custome.js in this line

PIE.attach(this);

Share Improve this question edited Jul 3, 2015 at 19:07 MarsAtomic 10.7k5 gold badges36 silver badges58 bronze badges asked Nov 2, 2012 at 6:21 subodhsubodh 6,15813 gold badges52 silver badges73 bronze badges 4
  • is PIE.js an external library? – Florian Margaine Commented Nov 2, 2012 at 9:32
  • @FlorianMargaine, No, I have PIE.js in my application folder in same place where custom.js is. – subodh Commented Nov 2, 2012 at 9:40
  • Yes, but is it an external library? Where did you get it from? – Florian Margaine Commented Nov 2, 2012 at 9:42
  • Yes it is an external library. I don't know from where the UI team get it, But I know that they are downloaded it from the google. – subodh Commented Nov 2, 2012 at 9:47
Add a comment  | 

1 Answer 1

Reset to default 17

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;
}
发布评论

评论列表(0)

  1. 暂无评论