So, given the following markup, if a users browser has JavaScript disabled, they will be redirected to an alternate page that either attempts to emulate the sites functionality without JavaScript (perhaps a dynamically rendered page), or a warning page, informing the user that JavaScript must be enabled to use the site开发者_StackOverflow社区
<!doctype html>
<html>
<head>
<!-- If the browser has javascript disabled, the browser will be redirected-->
<!-- to a page that does not require javascript to function, or informs the-->
<!-- the user of the requirement for javascript to be enabled-->
<noscript>
<meta http-equiv="refresh" content="5; url=/warning.html"/>
</noscript>
<title>
Page Title
</title>
</head>
<body>
<script>
// rich client logic
</script>
</body>
</html>
Judging by this html5 validator as well as the w3c validator it would appear that the above is valid html5. I'm considering using this technique to manage users that do not have JavaScript enabled and thereby cannot use the single page application I'm planning, but I haven't seen it before and was wondering if
(a) has anyone used this technique in production before and care to share their experiences
(b) can anyone offer up any valuable criticism as to why I shouldn't consider using this technique?
Right now its looking like a viable option to me, but I'm not wholly confident of the potential side effects (such as the conditions under which a browser would NOT respect the redirect).
can anyone offer up any valuable criticism as to why I shouldn't consider using this technique?
You have a very fragile system. If the JS fails for any reason, it will break completely. Search engines could spider both versions of the site and link people to the "wrong" one.
So don't do that. Use feature detection and build on things that work.
I use this technique and it works perfectly well. I just add this line to the no JavaScript page:
<META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW">
I used to disagree with this approach and recommend progressive enhancement but it just doesn't make sense to do this any more because:
1: About 1% of users will disable JavaScript, its a lot more than 1% more work to support them. (last years stats see: http://developer.yahoo.com/blogs/ydn/posts/2010/10/how-many-users-have-javascript-disabled/)
2: There isn't always any alternative to javascript.
精彩评论