Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  103] [ 4]  / answers: 1 / hits: 18592  / 12 Years ago, fri, april 6, 2012, 12:00:00

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?


More From » jquery

 Answers
27

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


[#86388] Wednesday, April 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yisroels

Total Points: 256
Total Questions: 94
Total Answers: 102

Location: Chad
Member since Mon, Dec 5, 2022
1 Year ago
;