-1

The tested and supported platform for my application is Windows based computer with IE as browser. If the browser which the user uses is not Internet Explorer then my application should not permit the user to log in.

How do I do this. Thanks in advance

suresh
  • 943
  • 2
  • 8
  • 22

1 Answers1

1

Well, if you really want to detect the usage of IE (although in most cases detecting browser supported features would be better), you can check if the User Agent is Internet Explorer, and if not, disable login.

In the below code snippet from Microsoft, getInternetExplorerVersion() returns -1 is the browser is not IE, and returns the version if the browser is IE. Based upon the value of this function, you can decide whether or not to enable login.

Example

var IEdetected = getInternetExplorerVersion();
if (IEdetected == -1){
     // disable login
}

IE Detection Code from MSDN

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  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 >= 8.0 ) 
      msg = "You're using a recent copy of Internet Explorer."
    else
      msg = "You should upgrade your copy of Internet Explorer.";
  }
  alert( msg );
}

Browser Detection Code from MSDN Article Detecting Windows Internet Explorer More Effectively

KernelPanik
  • 8,169
  • 1
  • 16
  • 14