Dmitry Chornyi
Dmitry Chornyi

Reputation: 1871

Javascript to detect an old Internet Explorer and offer to download newer browser(s)

I'm looking for something good-loking that I can paste on a page and be done with it.

The script should detect IE versions older than 9 and show a nice popup with links to different browsers or something like that. I could do it myself, but I'd rather not reinvent the wheel.

Upvotes: 1

Views: 8434

Answers (4)

Josh Davenport-Smith
Josh Davenport-Smith

Reputation: 5511

When I first posted this answer, the modern.IE project were pushing the IE6 countdown initiative, part of which was the provision of a IE detection snippet and hosted image used to warn users that they're using an old browser.

I originally linked to http://www.ie6countdown.com/ which now redirects to an area on modern.IE which no longer provides the snippet and image. So, for prosperity and reference, here is the code they were sharing and the original banner image hosted on imgur:

<!--[if lt IE 7]>
<div style=' clear: both; height: 59px; padding:0 0 0 15px; position: relative;'> 
  <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode">
    <img src="http://i.imgur.com/hNingci.jpg" border="0" height="42" width="820" alt="" />
  </a>
</div>
<![endif]-->

If you want to change this to detect IE versions less than 9 just change the first bit of the code to this:

<!--[if lt IE 9]>

Upvotes: 10

katzmopolitan
katzmopolitan

Reputation: 1381

This one offers customizable browser versions, not just for IE but also for Firefox, Opera, Safari. http://browser-update.org/

Upvotes: 5

nmsdvid
nmsdvid

Reputation: 2898

Recently I developed a free jQuery plugin that shows a well designed warning message to the visitor who's trying to view your site with an older version of Internet Explorer browser.
Site: http://nmsdvid.com/iealert/

Upvotes: 1

zellio
zellio

Reputation: 32484

I would probably use a comment hack with IE conditional comments to do the version detection.

<!--[if lt IE 8 ]>
    <script type='text/javascript'>
        alert( 'Your IE is Old' );

        // or set a flag or something

        var oldIE = true;
    </script>
<![endif]-->

It's technically not using javascript to do the detection and is rather using a feature inherent to IE but it should work more consistently than a complex javascript function.

Upvotes: 6

Related Questions