CSS3Pie causing startup error

2019-06-19 17:10发布

问题:

When importing CSS3Pie, I'm getting the following error.

Uncaught TypeError: Object [object DOMWindow] has no method 'attachEvent'

I am using Chrome. Is this possibly something I have caused, or just a bug. Thanks!

回答1:

I think you should be importing the "PIE.js" file in an IE-only conditional comment:

<!--[if IE]>
  <script src='PIE.js'></script>
<![endif]-->

The CSS3Pie project is an Internet Explorer facility - it only works on IE, and is completely useless for all other browsers.

edit — note that this is if you're importing the stuff as a .js file in the first place. As far as I can tell, the CSS3Pie docs all encourage the functionality to be imported via the IE "behavior" CSS attribute. That attribute will just be ignored by Chrome and Firefox and Safari and everything else that's not IE.