Start browser update if IE8 or older

I wonder if it is possible to show a warning or open a pop-up window in which, say, update your IE to the latest version or use Firefox / Chrome / Safari if the browser is Internet Explorer IE8 or older ...

I think I should use this code below inside the tags ...

<!--[if lt IE 9]> ...i should use code here... <![endif]--> 

Is it smart to share a browser using jQuery and load jQuery lib? Or is it better to just use regular javascript to avoid additional problems with very old browsers?

+6
source share
7 answers

You have two options:

  • Expand User-Agent String

     // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). function getInternetExplorerVersion() { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) { rv = parseFloat( RegExp.$1 ); } } return rv; } function checkVersion() { var msg = "You're not using Internet Explorer."; var ver = getInternetExplorerVersion(); if ( ver > -1 ) { if ( ver >= 9.0 ) { msg = "You're using a recent copy of Internet Explorer." } else { msg = "You should upgrade your copy of Internet Explorer."; } } alert(msg); } 
  • Using conditional comments:

     <!--[if gte IE 9]> <p>You're using a recent version of Internet Explorer.</p> <![endif]--> <!--[if lt IE 8]> <p>Hm. You should upgrade your copy of Internet Explorer.</p> <![endif]--> <![if !IE]> <p>You're not using Internet Explorer.</p> <![endif]> 

Link: More Effective Internet Explorer Discovery

+6
source

You can use something like this

Warning ie6-upgrade is a little script (7.9kb) that displays a warning message that politely informs the user about updating the browser to a newer version (links to the latest IE, Firefox, Opera, Safari, Chrome provided).

The webpage is still displayed behind a transparent background, but access to it is denied. The idea is to get users to upgrade from IE6 and avoid the bad reputation of the website that the website does not display correctly in IE6.

the script is fully translated into any language, it is very easy to configure (one line of code on a web page and one parametric configuration).

Although it was created for use with IE6 users using the correct options, you can use it for your scenario.

+6
source
 <script> var ISOLDIE = false; </script> <!--[if lt IE 9]> <script> var ISOLDIE = true; </script> <![endif]--> 

Then later, when you want to draw a line to support older versions of IE in your code:

 <script> if(ISOLDIE) { alert("Your browser currently does not support this feature. Please upgrade."); window.location = 'http://google.com/chrome'; } </script> 

It is generally not recommended to completely remove IE8 support, so I think the above solution is a good compromise, because you can add it to the components of your website / web application, which is simply impossible to do to support IE8, but then you could (possibly) still supporting IE8 in other areas of your site.

+5
source

This Dutch site forces IE6 and lower users to update their browser by slightly adjusting the β€œIf IE” code, which you can block from any version that you like.

http://wijstoppenook.nl/nl/

Go to step 4 and click "download" or "voorbeeld" to demonstrate, the first one is the top banner, the second completely blocks the page.

The only drawback, everything is in Dutch, so you have to compose your own message.

+2
source

Conditional comments are no longer supported in IE 10. WTF! Link

+1
source

On your site, add your code in index.html or index.php

His work is also joomla and wordpress.

 <!--[if IE 5]> <script language="Javascript"> <!-- alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.") //--> </script> <![endif]--> <!--[if IE 5.0]> !-- alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.") //--> </script> <![endif]--> <!--[if IE 5.5]> !-- alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.") //--> </script> <![endif]--> <!--[if IE 6]> !-- alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.") //--> </script> <![endif]--> <!--[if IE 7]> !-- alert ("It looks like you aren't using Internet Explorer 7. To see our site correctly, please update.") //--> </script> <![endif]--> <!--[if IE 8]> !-- alert ("It looks like you aren't using Internet Explorer 8. To see our site correctly, please update.") //--> </script> <![endif]--> 
0
source

There are many ways, but this is by far the most elegant: http://outdatedbrowser.com/en/how

0
source

Source: https://habr.com/ru/post/912609/


All Articles