306 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Kontent says

Hi, try this:

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

// Stuff here

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

// Stuff here 

<!--<![endif]-->
306 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 1 000 and 5 000 dollars
  • United States
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
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
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 :)

3118 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 3-4 years
  • Exclusive Author
chrisakelley says

EDIT :nevermind kontent fixed it :)

349 posts
  • Bought between 1 and 9 items
  • Has been a member for 5-6 years
al_m473 says

brainbuzzmedia

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

Al

306 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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.

306 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
brainbuzzmedia says

And it works!

Very nice, thanks a lot.

193 posts
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Kontent says
And it works! Very nice, thanks a lot.

You’re welcome :)

by
by
by
by
by
by