views:

455

answers:

4

I have a site which relies heavily on javaScript. I created a mirror site, which has all the JS as well as all the elements that require JS removed. What is a good, easy way to redirect users to the mirror site if they don't have javaScript enabled?

I tried this, but it doesn't seem very good:

<noscript>
  <meta http-equiv="refresh" content="0; URL=nojs/index.php">
</noscript>

I also tried to putting header-redirect into the noscript tag, but that didn't work.

+4  A: 

What is your definition of "not very good"?

All my sites use:

<noscript>
  <meta http-equiv="refresh" content="0; url=http://www.sadtrombone.com/" />
</noscript>
Coronatus
`<meta>` is only valid inside the head, because it modifies headers. `<noscript>` is only valid inside the body, because it handles content. As such, they are not mixable and may not work as intended in all web browsers.
Mikael S
@Mikael: 1) Having HTML validate 100% strictly according to the W3C standard is not important. 2) It works on all major browsers.
Coronatus
What I mean is that the redirection is not seamless. It goes to the first site and only redirects after a split second. Therefore it is not very good.
zeckdude
@Michael Boyd: Professionals will disagree with you on this point.
Johannes Gorset
+7  A: 

Make the no-JavaScript version of the site the default. Include a small script in there to redirect to the scripted site.

Or, abandon the use of a redirect entirely and go with Progressive Enhancement

Matt
... thus redirecting 99% of visitors rather than 1%. Semantically, I agree with your sentiments, but all things considered I don't think it's a very good idea.
Johannes Gorset
@FRKT, Hopefully the page is cache-able, thus redirecting would be fast enough. This may be an issue with sites with lots of traffic, but with a fast enough connection I don't think this will be a major issue. Only one way to find out, of course.
strager
Well, the ideal solution in this case would be to use Progressive Enhancement instead of a redirect.
Matt
A client side redirection is annoying, because the URL that appears in the bar changes. Imagine if every time you went to google.com, it redirected you to http://www.google.com/js/And yes, some sites do do that, but I still think it is bad practice, needlessly slowing down the client experience.
Sasha
@Sasha, Not respecting progressive enhancement is bad practice, even.
strager
I agree with FRKT and Sasha, most of the users have JS enabled, so redirecting the world instead of a few people, is a bit overkill.
N 1.1
I decided to do Progressive Enhancement. It's a bit more work, but I see how it is better. Thanks for the suggestion!
zeckdude
+19  A: 
<noscript>
    <p>This site is best viewed with Javascript. If you are unable to turn on Javascript, please use this <a href="http://sitewithoutjavascript.com"&gt;site&lt;/a&gt;.&lt;/p&gt;
</noscript>

Some people purposely disable Javascript, and you might want to give them a chance to turn it on before redirecting them.

Chacha102
I wish I could upvote this more than once.
Johannes Gorset
Ahhhhhhhhhhhhh!
strager
+4  A: 

I wouldn't do client-side redirection, as that might seem annoying to the user. Instead, what I would do is use <noscript> to show the content of this JS-less site on the same page. It may be more work, but it would definitely be a smoother experience.

Sasha