308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

I am having a bit of a problem. I have a jquery script that isn’t working right in IE. I need to load one version of the code for all other browsers and a different version for IE. What is the easiest way to do this?

I can’t use just an IE conditional, because I can’t have the non IE version showing up in IE.

193 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $100+ on Envato Market
  • Sells items exclusively on Envato Market
Kontent says

Hi, try this:

If it’s not IE…
<!--[if !IE]><!-->

// Stuff here

<!--<![endif]-->
If it is IE…
<!--[if IE]><!-->

// Stuff here 

<!--<![endif]-->
308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

To me those look like the same code. How does one go to IE and one go to the other browsers?

443 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
SplitV says

You can do browser sniffing on the server side, but that isn’t really reliable. Other then that jQuery has a browser object you can use to detect the browser and only execute certain code for IE and other code for everything else.

But the ideal solution would be to do feature detection instead of browser detection.

193 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $100+ on Envato Market
  • Sells items exclusively on Envato Market
Kontent says
To me those look like the same code. How does one go to IE and one go to the other browsers?

Updated sorry :)

3437 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 4 years
+1 more
organicbee says

EDIT :nevermind kontent fixed it :)

353 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 1+ items on Envato Market
al_m473 says

brainbuzzmedia

notice that one of the IE’s has a ”!” in front of it, makes all the difference

Al

308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says
brainbuzzmedia

notice that one of the IE’s has a ”!” in front of it, makes all the difference

Al

It wasn’t like that when it was first posted.

Actually, I think it should be like this:

<\\IE]><!—>

// Stuff here

<\\[endif]—>

If it is IE…

<!—[if IE]>

// Stuff here

<\\[endif]—>

Need to take the ”>” off of the one for IE, because that would end the comment otherwise.

308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

And it works!

Very nice, thanks a lot.

193 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $100+ on Envato Market
  • Sells items exclusively on Envato Market
Kontent says
And it works! Very nice, thanks a lot.

You’re welcome :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by