Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force browser update if IE8 or older

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

I guess I should use that code below inside the tags...

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

Is it smart to deceted browser with jQuery and loading jQuery lib? Or is it better to just use regular javascript in order to avoid additional issues with very old browsers?

like image 603
ProDraz Avatar asked Apr 06 '12 14:04

ProDraz


People also ask

Why should you update your browser on a regular basis?

By updating your browser, you'll get the latest in features and functionality in addition to security fixes that can keep you safer out there.

How do I remove Internet Explorer as my default browser?

Select the Start button, and then type Default apps. In the search results, select Default apps. Under Web browser, select the browser currently listed, and then select Microsoft Edge or another browser.

How do I enable Internet Explorer settings?

There are many changes you can make to customize your browsing experience in Internet Explorer. To view all settings and options, open Internet Explorer on the desktop, select Tools > Internet options.


2 Answers

You have two options:

  1. Parse the the 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);
    }
    
  2. 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]>
    

Reference: Detecting Windows Internet Explorer More Effectively

like image 140
antonjs Avatar answered Oct 05 '22 22:10

antonjs


You could use something like this

The ie6-upgrade-warning is a little script (7.9kb) that displays a warning message politely informing the user to upgrade the browser to a newer version (links to newest IE, Firefox, Opera, Safari, Chrome are provided).

The webpage is still visible behind a transparent background, but access to it is prevented. The idea is to force users to upgrade from IE6 and avoid the website from a bad reputation that website is not rendering correctly in IE6.

The script is completely translatable in any language, very easy to set-up (one line of code in webpage and one parametter configuration).

Although was created to be used with IE6 users, using the correct parameters you can use it for your scenario.

like image 24
Claudio Redi Avatar answered Oct 06 '22 00:10

Claudio Redi