Detecting browser version with javascript for google swiffy compatibility

926 Views Asked by At

Hi there I'm trying to find a way to redirect unsuported browsers from a swiffy based html5 interactive.

Unfortunately I have no experience of browser/feature detection so I just have a basic skeleton for my code:

// this line would confirm compatible browser is present and sends to a swiffy html5 page:

if(navigator.appName == "Chrome 18.0+" ||  "Firefox 4+" || "Safari 5.1+" || "Internet Explorer 9+" || "Opera 12+" || "Mobile Safari iOS 5+" || "Android 4.0.3+")
{
 window.location = "timeline_web.html"
}
else{

// this line sends other browsers to fallback .png based version:

window.location = "timeline_web_fallback.html"
}

If you have any idea how to set this up I would be extremely grateful! Hope you can help

2

There are 2 best solutions below

0
On BEST ANSWER

My solution is to use a browser detecting jquery plugin here:

http://jquery.thewikies.com/browser/

to check against every browser version. Seems to be working well so far, with nice simple code :-)

0
On

Feature detection is usually better than browser version detection, as feature availability might depend on other factors like the doctype. You can test specific features, or use a library like modernizr