-3

I have this piece of code here:

        print "<p id=\"up\" style=\"position:absolute;top:33px;\">+$row_thumbs_up</p>";
        print "<p id=\"down\" style=\"position:absolute;bottom:33px;\">-$row_thumbs_down</p>";

Now, I wanted it so if the browser is IE version 9 or less, then this will be shown instead:

        print "<!--[if lte IE 9]><p id=\"up\" style=\"position:absolute;top:43px;\">+$row_thumbs_up</p>";
        print "<p id=\"down\" style=\"position:absolute;bottom:43px;\">-$row_thumbs_down</p><![endif]-->";

Now this works fine, except if someone is using IE 9 or less, then both are shown of course, when I only want the bottom code to be shown and the top to be shown if anything else if used, such as IE 10, Chrome, Firefox, Opera, etc. I'm really stuck here.

halfer
  • 18,701
  • 13
  • 79
  • 158
user3332590
  • 91
  • 1
  • 1
  • 9

1 Answers1

0

Just do something like:

print "<!--[if (gt IE 9)|(!IE)]<p id=\"up\" style=\"position:absolute;top:43px;\">+$row_thumbs_up</p><![endif]-->";
print "<!--[if lte IE 9]><p id=\"down\" style=\"position:absolute;bottom:43px;\">-$row_thumbs_down</p><![endif]-->";

The top line will be displayed for IE 10+, and all other browsers, while the bottom line will be shown for IE9 and below.

FreeAsInBeer
  • 12,837
  • 5
  • 46
  • 79
  • html if statements are not supported in IE versions 10 and above, so nothing would be displayed in IE 10 or above. So this wont work – user3332590 Apr 28 '14 at 12:51
  • @user3332590 In that case, you can always check via JavaScript and append a CSS class. http://stackoverflow.com/a/13954700/632736 What's the reason you're wanting to show different UI based upon the browser? The current standard is to detect features, not browsers. – FreeAsInBeer Apr 28 '14 at 12:54
  • Then use `` instead … http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment – CBroe Apr 28 '14 at 12:55