If Browser is Internet Explorer: run an alternative script instead

后端 未结 10 583
后悔当初
后悔当初 2020-11-29 05:11

I\'m using an image carousel script that is quite heavy on the browser. It works great in Opera and Chrome, half decent in FF and absolutely breaks my balls in IE. So i\'d l

相关标签:
10条回答
  • 2020-11-29 05:55

    Here is the script i used and it works like a charm. I used the boolean method Ender suggested as the other ones using only the IE specific script adds something to IE but doesn´t take the original code out.

        <script>runFancy = true;</script>
    <!--[if IE]>
    <script type="text/javascript">
        runFancy = false;
     </script> // <div>The HTML version for IE went here</div>
    <![endif]-->
    
        // Below is the script used for all other browsers:
        <script src="accmenu/acac1.js" charset="utf-8" type="text/javascript"></script><script>ac1init_doc('',0)</script> 
    
    0 讨论(0)
  • 2020-11-29 05:59

    Note that you can also determine in pure js in what browser you script is beeing executed through : window.navigator.userAgent

    However, that's not a recommended way as it's configurable in the browser settings. More info available there: https://developer.mozilla.org/fr/docs/DOM/window.navigator.userAgent

    0 讨论(0)
  • 2020-11-29 06:00

    This article is quite explanatory: http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx.

    If your JS is unobtrusive, you can just use:

    <![if !IE]>
       <script src...
    <![endif]>
    
    0 讨论(0)
  • 2020-11-29 06:01

    See this script in Microsoft's developer archives: https://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx

    I have used this script in quite a few projects, never had any problems.

    0 讨论(0)
提交回复
热议问题