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

☆樱花仙子☆ 提交于 2019-12-30 12:04:11

问题


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.


回答1:


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]>



回答2:


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.




回答3:


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




回答4:


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/



来源:https://stackoverflow.com/questions/10212503/javascript-to-detect-an-old-internet-explorer-and-offer-to-download-newer-browse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!