12

I have been looking around and cannot find what I am looking for

I want to display a warning to IE users that my website does not support IE nor will it ever try to and that you should get a better browser.

How you detect IE is really all I need but it would be nice if someone told me how to trigger a lightbox on the page but I can do that myself if you don't include it

Thank's for the help!

b2550
  • 490
  • 2
  • 5
  • 18

4 Answers4

24

Conditional HTML comments will work for detecting IE9 or less. From the HTML5 Boilerplate, which I highly suggest you use:

<!--[if lt IE 7]>
    <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
elclanrs
  • 92,861
  • 21
  • 134
  • 171
  • Wait, what is Boilerplate? I looked at it and still don't know really what it does... – b2550 Jan 27 '13 at 05:59
  • 1
    Boilerplate is a template to get you started with a new web project very quickly and it provides some very useful defaults. There are boilerplates for anything. If it's been done before better use it, that's the idea of a boilerplate. – elclanrs Jan 27 '13 at 06:05
  • 1
    When did HTML get commented if statements? :) – Kellen Stuart Jan 16 '19 at 19:12
  • 1
    @KolobCanyon It didn't. Most browsers will treat that as one big comment. Only IE will know what to do with it, and will if version matches condition show the contained html. This is non-standard browser specific syntax. – AntonChanning Aug 14 '19 at 08:36
1

Try this

 if ($.browser.msie) {
    // you are using IE
 }

More detail : jquery.browser

Iswanto San
  • 18,263
  • 13
  • 58
  • 79
  • From the jQuery Docs: _"We recommend against using this property; please try to use feature detection instead (see `jQuery.support`). `jQuery.browser` may be moved to a plugin in a future release of jQuery."_ – elclanrs Jan 27 '13 at 05:58
  • @elclanrs no. Feature detection is a better approach for coding javascript for different browsers, the OP wants to specifically detect which browser the user is using. – Benjamin Gruenbaum Jan 27 '13 at 05:59
  • 2
    Yes, then I want to tell the person that if they are using IE, it sucks and that they should get a new browser – b2550 Jan 27 '13 at 06:01
  • @b2550: The key is to actually _do_ feature detection instead of browser detection, because IE9 is very capable, and many people use it, you're basically losing 40% of your users. For IE8-7-6 it might be enough to do a simple `userAgent` check (which is what `$.browser` does), otherwise for newer IE version feature detection is the way to go. – elclanrs Jan 27 '13 at 06:02
  • @elclanrs My website still works fine with IE but IE also does not contain features my site uses. It mostly is a joke and kind of is a tip to make the site look better. – b2550 Jan 27 '13 at 06:05
  • @b2550: Think _graceful degradation_. Users that don't see those features won't ever know they were there to start with. My advice, if it's purely aesthetics don't worry about it. – elclanrs Jan 27 '13 at 06:07
  • @elclanrs Most of the site itself will work with IE until we get to some other parts that use HTML5 canvases and stuff. I just want to know and that is it. – b2550 Jan 27 '13 at 15:39
1

navigator object has all details related to browser and platform details of clients machine.

navigator.userAgent gives browser related details.

JS snippet:

<script>
  var x = navigator.userAgent;
  alert(' browser details ' + x);
</script>

Below link talks at length about it in detail :

http://www.javascriptkit.com/javatutors/navigator.shtml

rai.skumar
  • 10,309
  • 6
  • 39
  • 55
0

Paste the code after tag:

  <!--[if lt IE 8]>
  <p class="browserupgrade">Vous utilisez un <strong>ancien navigateur</strong>. Mettez votre <a href="http://browsehappy.com" target="_blank">navigateur à jour</a> dès aujourd'hui !</p>
  <![endif]-->

PS: edit the content as you need. I translate it into French for my own use.

Yoav
  • 1
  • 1