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

javascript - IE8 is throwing error with jQuery - Stack Overflow

programmeradmin2浏览0评论

I'm facing some issue with IE7/IE8 and jQuery. My code works in IE 10, FF, Chrome, Safari, Mobile Safari, Mobile Chrome.

For now, to debug, I've removed my own JS file. So here's the code:

<script type="text/javascript" src="//ajax.googleapis/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

There is no other JS referenced on this page. I've removed all other JS reference and there is no JS executed on the page itself. When the page loads in IE8, I get this error:

Line: 4
Error: Object doesn't support this property or method

The debugger shows the above. Not sure where the issue is. Any help is greatly appreciated.

P.S. - This is my first 'serious' web development effort and I see now why IE is hated so much in the dev community.

I'm facing some issue with IE7/IE8 and jQuery. My code works in IE 10, FF, Chrome, Safari, Mobile Safari, Mobile Chrome.

For now, to debug, I've removed my own JS file. So here's the code:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

There is no other JS referenced on this page. I've removed all other JS reference and there is no JS executed on the page itself. When the page loads in IE8, I get this error:

Line: 4
Error: Object doesn't support this property or method

The debugger shows the above. Not sure where the issue is. Any help is greatly appreciated.

P.S. - This is my first 'serious' web development effort and I see now why IE is hated so much in the dev community.

Share Improve this question asked Jun 30, 2013 at 16:01 DS.DS. 3,0046 gold badges32 silver badges37 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 13

jQuery 2.0 dropped support for some browsers. See the release post at http://blog.jquery.com/2013/04/18/jquery-2-0-released/

Quoting from the post:

No more support for IE 6/7/8: Remember that this can also affect IE9 and even IE10 if they are used in their “Compatibility View” modes that emulate older versions. To prevent these newer IE versions from slipping back into prehistoric modes, we suggest you always use an X-UA-Compatible tag or HTTP header. If you can use the HTTP header it is slightly better for performance because it avoids a potential browser parser restart.

Reduced size: The final 2.0.0 file is 12 percent smaller than the 1.9.1 file, thanks to the elimination of patches that were only needed for IE 6, 7, and 8. We had hoped to remove even more code and increase performance, but older Android/WebKit 2.x browsers are now the weakest link. We’re carefully watching Android 2.x market share to determine when we can cross it off the support list, and don’t expect it to take very long.

Keep jQuery 1.9 (Edit 2015-11-17: jQuery 1.11.3 is the current 1.x version of jQuery.) if IE 6/7/8 are a concern.

use the code in the below linked gist in your html file and add both jquery 2.0+ for latest browser and 1.9 for older browsers

https://gist.github.com/dwoodiwiss/5633393

I faced the same issue, Actually I was referencing scripts like this;

<script src="../js/jquery-ui.js" type="text/javascript"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>

I fixed this by changing scripts referencing order by calling jquery.min.js first.

<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/jquery-ui.js" type="text/javascript"></script> 

Add the following in the web.config:

<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=EmulateIE8" />
      </customHeaders>
    </httpProtocol>
</system.webServer>
发布评论

评论列表(0)

  1. 暂无评论