Note that there are some explanatory texts on larger screens.

plurals
  1. PORun JQuery function when browser is IE
    text
    copied!<p>I am trying to run a JQuery function based on whether or not the user is running IE. The reason is because the function that I have does not work in IE, so I have another one I would like to run instead when the user is using IE. I am running JQuery 1.9.1, so I cannot use <code>$.browser</code>. I'm trying to use conditional comments, but I'm not sure if that is the way to go. I've tried to implement it here, but it doesn't work: <a href="http://jsfiddle.net/AsQ4E/" rel="nofollow">http://jsfiddle.net/AsQ4E/</a></p> <p>This is the HTML</p> <pre><code>&lt;!--[if IE]&gt; &lt;input type="button" onclick="javascript:ie();" value="Click Me!" /&gt; &lt;![endif]--&gt; &lt;!--[if !IE]&gt; --&gt; &lt;input type="button" onclick="javascript:notIE();" value="Click Me!" /&gt; &lt;!-- &lt;![endif]--&gt; </code></pre> <p>This is the JQuery</p> <pre><code>function ie() { alert("You are using IE"); } function notIE() { alert("You are not using IE"); } </code></pre> <p>How can I get this to work? Is this the best way to go about it?</p> <hr> <p>EDIT: I am trying to use SVG Crowbar. When the user clicks a button, Crowbar extracts an SVG from the page and pops up a download for it. Here is the link to it: <a href="http://nytimes.github.io/svg-crowbar/" rel="nofollow">http://nytimes.github.io/svg-crowbar/</a>. The problem is is that it doesn't work in IE, so I was going to use this only when the user is using IE: <a href="http://bl.ocks.org/biovisualize/1209499" rel="nofollow">http://bl.ocks.org/biovisualize/1209499</a> (This works in IE). I don't know enough about programming and Javascript to debug the problem with IE.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload