I've created a website which contains experimental HTML5 stuff. So old browsers can't display it.

Now I want to detect if it is an old browser which the visitor uses and redirect it to a subfolder called "/old", where I display my website as a non-HTML5 website and display a hint that the user is using an old browser.

How can I redirect the user if he's using an old browser?

有帮助吗?

解决方案

Use Modernizr

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

Why use Modernizr?

Taking advantage of cool new web technologies is great fun, until you have to support browsers that lag behind. Modernizr makes it easy for you to write conditional JavaScript and CSS to handle each situation, whether a browser supports a feature or not. It’s perfect for doing progressive enhancement easily.

其他提示

You should never detect browsers. Insted detect features browser support. Here's a good article on how to do this: Detecting HTML5 Features

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top