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 3 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 4 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 3 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 :)

3231 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 5 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 3 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 :)

by
by
by
by
by
by