Jump to content

Detect Internet Explorer with Javascript


Protopop
 Share

Recommended Posts

My site NimianLegends.com has not been thoroughly tested in Internet Explorer. So for the time being I detect Internet Explorer and redirect the user to another page using this method:

if(window.ActiveXObject || "ActiveXObject" in window){    // Always true if browser is Internet Explorer    window.location = 'pages/core/ie.htm';}

Works flawlessly. Except....

 

Google's spiders must use activeX because on the Google results page it always shows the ie.htm page.

 

Is there another simple, rock solid method to detect Internet Explorer in Javascript?

Link to comment
Share on other sites

Thanks dhaber. I've read that Microsoft intentionally broke this kind of detection in IE 11.

 

BUT...

 

Reading your suggestion it occurs to me that i can use this to detect earlier versions of IE before the change.

 

The site works almost 100% in IE 11 so i could use your code to keep out IE 9 and below, which is really what I want to do.

 

Thanks so much - sometimes marinating ideas and hearing suggestions helps come up with new views:)

Link to comment
Share on other sites

Thanks enpu - i hadnt heard about that - it sounds very clean.

For the moment ive used dhaber's suggestion. Worked great! since it doesnt work to detect IE11 that browser just passes through.

If it's IE 10 (which is also detectable by the way you suggested) it catches it and sends it through.

IE9 or less is refused:)
 

var isIE10 = false;if (navigator.userAgent.indexOf("MSIE 10") > -1) {        // this is internet explorer 10        isIE10 = true;}var isIE = (navigator.userAgent.indexOf("MSIE") != -1);if(isIE){    if(!isIE10){    window.location = 'pages/core/ie.htm';    }};
Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

Works flawlessly. Except....

 

Google's spiders must use activeX because on the Google results page it always shows the ie.htm page.

 

Is there another simple, rock solid method to detect Internet Explorer in Javascript?

 

It sounds like your real issue isn't IE detection, it's robot / crawler prevention?  Why not create a robots.txt with the following?

User-agent: Googlebot Disallow: /pages/core/ie.htm 

From: http://tools.seobook.com/robots-txt/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...