I’m trying to redirect older browsers that don’t support CSS3 or iFrames to a warning page where I explain that they may experience problems with their older browsers if they continue.
The script (or otherwise) should test for css3 comparability and not browser id.
A banner that displays at the top of the page if the user is viewing using a older browser would also be acceptable.
I’m currently using:
<!--[if lt IE 9]><div style=' clear: both; height: 200px; padding:0 0 0 15px; position: relative;'><a href="old"><img src="old-browser.jpg" border="0" height="153" width="659" alt="" /></a></div><![endif]-->
Is their Anyone have any experience with this or a link to an example? Thanks.
Testing for the browser version is an unreliable method – many users do not provide that information, and others tell you they are using a different browser then they really are. If you need specific features then the only reliable way to determine if they are available is to use javascript to see if they exist.
Are you determined to redirect, not just change what’s displayed? Because changing the contents of the current page would be much simpler. Just add something like this to your page:
CSS:
Now the page will load with #warning displayed, and you can use javascript to hide it if the required features are present (you don’t want to do the inverse and use javascript to display it because you want it displayed if your script doesn’t run). There are a lot of ways to do that, and the most “standard” way would be to attach an onload event. However, this is one situation where I think a hackish approach is much better. If you do the test on-load, then the warning will be displayed until the javascript executes, which could be anywhere from a fraction of a second to several seconds. What you really want to do is hide the element before it is ever displayed, and you can do that by adding something like this to the
<head>section.As per your example, this assumes that the features you need are textShadow, textStroke, boxShadow, borderRadius, borderImage, and opacity.
You really shouldn’t put any other javascript in the
<head>though, since the page won’t start rendering until the code above it finishes executing.