February 8th, 2012, 03:50 PM
Detect and Redirect Internet Explorer 9 ?
POSTEDetect and Redirect Internet Explorer 9 ?
Sorry fellas, I am a complete noob
I am trying to detect if a users browser is Internet Explore Version 9
the subsequently redirect that browser to a new page that is IE 9 specific in my directory. My code does NOT seem to be working.
Could any of you kind folks take a look and see the mistake?
if(navigator.appName == "Microsoft Internet Explorer"&& navigator.appVersion >=8)
window.location = "SeansWebsite_2012_IE9.html"
<!-- the page that i am starting on is "SeansWebsite_2012.html"-->
February 8th, 2012, 05:18 PM
Please use [code] tags when posting code. Thank you!
You can use Browser Sniffing to determine if it's IE9 by checking if window.msPerformance exists. Here's another way that also looks for Document Mode set to "IE9 standards".
Unless you're trying to show off something IE9 specific or display something using HTML5, I'd pause and consider why you need to detect. A site designed for the general public should be made to degrade gracefully, regardless of browser or version.
Comments on this post
I'd rather teach you to fish than give you a fish. I reserve the right to also slap you with the fish.
December 10th, 2012, 04:34 PM
Warning: The following is never the appropriate way to deal with browser differences. Instead of trying to sniff the users browser to determine which document has the appropriate markup, code according to standards, use a standards doctype, and make good use of progressive-enhancement.
That being said, there are still various valid reasons for wishing to know which browser your user is currently using, and as such the following is how I would accomplish this for IE9 users.
Personally, I would encourage you to avoid browser sniffing as it's a very unreliable practice. Instead, use what native features the browser affords to you. In the case of Internet Explorer 9, you could use Conditional Comments:
Please note that Conditional Comments won't work after IE9 as IE10 dropped support for many of the non-standard features of the browser.
<!--[if IE 9]>
alert("You appear to be using IE9");
More on Conditional Comments here: msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx