IE8: Object doesn't support this property or method

爱⌒轻易说出口 提交于 2019-12-21 18:32:02

问题


I know that my issue is known, I just can't figure out a way to fix the problem. However the code works in chrome,ff and safari, but not in ie6-8. I tried to debug the code and following popped up: Line: 272 Error: Object doesn't support this property or method

This is line 272 from my js-file

$('#page1')[0].addEventListener('webkitAnimationEnd', self.webkitAnimationEnd, true);

Hav you got an idea what is wrong with it? I'm using jquery <script type="text/javascript" src="js/jquery-1.4.3.min.js">;</script> which is called in my .html file.

I appreciate any help or useful hint. Thank you in advance.


回答1:


use attachEvent for IE here is a SO link MSIE and addEventListener Problem in Javascript?

your code may look like

if ( $.browser.msie ) {
$('#page1')[0].attachEvent('webkitAnimationEnd', self.webkitAnimationEnd);
}

hope that will help




回答2:


See mozilla docs for problem description and solution

var el = $('#page1')[0];
if (el.addEventListener){
  el.addEventListener('webkitAnimationEnd', self.webkitAnimationEnd, true);
} else if (el.attachEvent){
  el.attachEvent('webkitAnimationEnd', self.webkitAnimationEnd);
}


来源:https://stackoverflow.com/questions/7531462/ie8-object-doesnt-support-this-property-or-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!