Вопрос

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