<noscript> redirection

I want to redirect the user to a specific page if javascript is disabled. I tried this code:

<noscript><?php url::redirect('controller/method'); ?></noscript> // url::redirect is much like the location header 

to no avail ...

How to do it?

+7
php
source share
4 answers

You cannot use the meta refresh tag and then remove it using Javascript, because the browser is configured to redirect when reading the meta refresh tag, and it's too late for JS to manipulate it.

The only way is to either do what Daniel suggested, or show the link when there is no Javascript:

 <noscript> <a href="">Click here to continue</a> </noscript> 

Or you can try to fail gracefully: Are you planning to disable javascript?

+2
source share

Since the headers are already submitted, you will need to use standard HTML markup:

 <noscript> <meta http-equiv="refresh" content="0;url=noscript.html"> </noscript> 

Trying this for both Firefox and IE seems to work well ... With JavaScript enabled, the <meta> ignored. When it is disabled, the browser is redirected to noscript.html .

+19
source share

Cannot redirect based on whether javascript is disabled. Why not do the opposite - redirect if javascript is enabled?

 <script> window.location = "..."; </script> 
+5
source share

Add this as the first element in your body, create it so that it fits, and perhaps offer a link inside it to the noscript page:

 <div onload="return false;"> <!-- PAGE CONTENTS --> </div><noscript>JAVASCRIPT IS REQUIRED TO VIEW THIS PAGE</noscript> 

I use a more detailed method of this (which basically makes it look like a modal dialog and everything is beautiful) on pages where the client does not allow me to use more compatible tools. I have tested in IE6 + and all other major browsers with great success.

0
source share

All Articles