0

Please forgive me if this answer is somewhere else on this site or online. If it is, I sure haven't found it in the past several days of searching.

What I am hoping to find is an "accurate" method of detecting a browser and redirecting to a simple, static page if not a recent browser.

The samples I have found until now often have not provided an accurate representation of the actual browser being used. For instance:

  • When testing with Navigator 9, I'll get a message that I'm using Firefox 2
  • When testing with Maxthon 3, it reports I'm using IE 9.

My site displays correctly in all the current browsers I've been testing it with. But I wish I could have a basic static page for those .01% who still are using an old browser for whatever reason. They could still get some basic information from my site, as well as encouraged to update to a more current browser.

If anyone has any useful suggestions, I'd greatly appreciate them.

Thanks so much.

Cheers,

David

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
David12
  • 1
  • 1

2 Answers2

0

Browser detection is never perfect, for a variery of reasons. If you are using jQuery, you should look into jQuery.browser.

I'd try to detect the browser on the server side and do an HTTP redirect if the browser is something non-standard. Most decent frameworks have functionality to detect the browser from the user agent string. Again, this is not perfect, mainly because of the data browsers report. Also, if Maxthon reports it's IE, that's because it is based on IE and therefore the layout engine should be the same.

So you either

  • support a small number of browsers and cater for their quirks, sending all other browsers to a basic page (this sucks for future versions of browsers because they might be standards-compliant but they will still display your very basic page), or

  • you have a standards-compliant page for all browsers and then you define alternatives for the ones that give you problems.

I'd go for the second option. It usually all boils down to one version for all browsers, and a number of hacks for various versions of IE. Also, remember to avoid padding in your CSS and use margins instead.

In the end, you probably shouldn't be testing for browsers and version numbers, but supported features. Try using Modernizr.

alexg
  • 3,015
  • 3
  • 23
  • 36
0

The $.browser property is deprecated in jQuery 1.3. On jQuery support site, they strongly recommend to use the detection feature (JQuery.support) instead of the jQuery.browser property. Actually, this has been answered already in another question, please check here How can you detect the version of a browser?

Community
  • 1
  • 1
Elenation
  • 1
  • 1