Loading Image

Almost there...

Loading Image

Loading...

Check if browser is Internet Explorer (IE) and return version

This is quite a simple JavaScript function which checks if the current browser is Internet Explorer (IE). If yes it will return the version number. Although this function is limited up to version 10, as Edge isn't seen as Internet Explorer.
11 January 2017 - 10:00
Downloads: 458
Category: JavaScript
Check if IE and return version
Overview

This is quite a simple JavaScript function which checks if the current browser is Internet Explorer (IE). If yes it will return the version number. Although this function is limited up to version 10, as Edge isn't seen as Internet Explorer.

JavaScript Code:
<script type="text/javascript" language="javascript">
//CALLING THE FUNCTION
if(msieversion() <= 10){
    //DO SOMETHING HERE
    alert(msieversion());
}

//BEGIN CHECK THE IE VERSION
function msieversion() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");    

    // If Internet Explorer, return version number
    if (msie > 0){
        return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
    }
}
//END CHECK THE IE VERSION
</script>