Why does my page work in IE9's IE7 mode, but not in IE7 itself?

前端 未结 8 679
离开以前
离开以前 2021-02-01 05:10

I recently went live with our new home page, after heavily testing it in each of IE9\'s browser and document modes (not just compatibility mode, but actual IE7 and IE8

8条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 05:36

    First: always test on the actual browser. If we're talking about ie, use a virtual machine to test it. Never rely on "compatibility modes", "ies4linux", "ies4mac", "just use wine" and such. I've had a lot, but a LOT of headaches when not using virtual machines (you can use snapshots on your virtual machines - each snapshot is a browser version. This way you can have only one image but with multiple browsers).

    Second: do this problem happens even if you remove that slideshow section from your script.js? Did you check if, after removing that section and reloading your page if it isn't a cached version of the old script.js? Sometimes a cached version is the source of all problems.

    A little hack to fool your browser into not caching script.js is to add, when calling script.js from your markup, an arbitrary number (script.js?v=100 for example, and for each modification you do with your js, you modify this number. You can check SO's source, it uses a similar approach in some sections).

    Third: try to do, before the "negation" in your script:

    alert($.browser.msie);
    alert($.browser.version);
    alert($.browser.msie && $.browser.version <= 7.0);
    

    ...and see if ie alerts something or if it raises an exception. Sometimes ie will try to interpret your javascript, and raise an unknown exception for no reason whatsoever: if you don't catch it in a try/catch block everything will break from that point to the end of the script.

    I know, it's a trial-and-error approach, but we have to isolate everything and try to understand exactly what's causing the error. If needed, repeat the third advice along the slideshow section.

提交回复
热议问题