W3C Validator returns some meta and <noscript> related errors. Yes, there is noscript stuff placed in the head section.
Googling - "noscript meta redirect validation".
A page that does not validate.
Tags: noscript, redirect, meta
A colleague has created the following code. If the user has javascript turned off, he is redirected to another page. The catch is that this code is part of the <body>, and a <meta> tag is not allowed in the body element, and the <noscript> tag is not allowed in the <head>. The refresh cannot be handled by javascript, as javascript is turned off.
<noscript> <meta http-equiv="Refresh" content="0; URL=../error/errorjs.jsp" /> </noscript>
Any ideas how to solve this..?
The <noscript> Tag
While the vast majority of users visiting your site will have JavaScript enabled - according to The Counter the current proportion is around 95% - you need to cater for the small number of users who will choose to disable scripting. The classic way of doing this is by placing the <noscript>.</noscript> tag pair directly into the body section of a webpage. We have on occasion used a more elegant technique. The code
<noscript> <meta http-equiv="refresh" content="0; url=http://www.yoursite.com/noscripts.html"/> </noscript>
is placed in the head section of every page accessible from this site. This ensures that the viewer is redirected to the noscripts page if JavaScript has been disabled in his/her browser. The HTML for our noscripts page is given below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta name="description" content="JavaScript Disabled!"> <meta http-equiv="refresh" content="5;url=http://www.yoursite.com"> <title>Please Enable JavaScript!</title> </head> <body> <pre> Dear Visitor, Thank you for... </pre> </body> </html>
The message regarding the need to enable JavaScript is nothing out of the ordinary. However, note the use of the meta refresh tag in the document header. This causes the YourSite home page, index.shtml, to be reloaded every five seconds. If scripting continue to be disabled the refresh embedded in the noscript tag on the index.shtml page will cause noscripts.html to be displayed all over again.
While it is allowed by default, IE7 enables users to turn off meta refresh. Consequently this technique for providing feedback regarding the need to enable scripting will not work with a very small proportion of visitors to the site. In our experience this number is too small to be of any significance.
A note of caution if you are considering using this technique - the code could send some search engine spiders into a loop whereby they read your <noscript> code and never get any further. Not all spiders are susceptible but it is best not to use this technique for pages which you want to get indexed.
It's black magic, but it's the black magic the Web is built on.
The best alternative is to do <noscript>foo</noscript> in the body of the page.
Foo may stand for - JavaScript is disabled in your browser! <a href="nojavascript.html" title="Please enable JavaScript">Please follow these steps to enable JavaScript</a>
Hooked by fish!