Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If Browser is Internet Explorer: run an alternative script instead

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 like to give IE users an alternative of simple HTML without any action/JS.

The script doesn't use MT or jQuery and its like 380 lines of JS. Would it be possible to give IE users a plain HTML alternative?

var browserName=navigator.appName; if (browserName=="Microsoft Internet Explorer") { // what command can i use? }

like image 911
dimmy4 Avatar asked Dec 10 '10 17:12

dimmy4


People also ask

How do I allow scripts to run in Internet Explorer?

Internet ExplorerClick Tools > Internet Options. Click the Security tab > Custom Level. In the Scripting section, click Enable for Active Scripting. In the dialog box that displays, click Yes.

Can all browsers always execute JavaScript?

JavaScript is a programming language that can run inside nearly all modern web browsers.

Does Internet Explorer use JavaScript?

As with most modern browsers, Internet Explorer supports JavaScript, which is enabled by default to allow users view dynamic interactions like display ads and animations on web pages.

Which script is run in browser?

To execute JavaScript in a browser you have two options — either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a . js extension) and then reference that file inside the HTML document using an empty script element with a src attribute.


3 Answers

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]>
like image 57
Flack Avatar answered Oct 12 '22 18:10

Flack


You can do something like this to include IE-specific javascript:

<!--[IF IE]>
    <script type="text/javascript">
        // IE stuff
    </script>
<![endif]-->
like image 20
Seth Avatar answered Oct 12 '22 20:10

Seth


For IE10+ standard conditions don't work cause of engine change or some another reasons, cause, you know, it's MSIE. But for IE10+ you need to run something like this in your scripts:

if (navigator.userAgent.match(/Trident\/7\./)) {
  // do stuff for IE.
}
like image 15
Y.Puzyrenko Avatar answered Oct 12 '22 20:10

Y.Puzyrenko