Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<noscript> redirection

Tags:

php

I want to redirect the user to a certain page if he/she has javascript disabled. I tried this code:

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

to no avail...

How do I do this?

like image 318
yretuta Avatar asked Nov 03 '09 03:11

yretuta


2 Answers

Since the headers have already been sent, you'll need to use standard HTML markup:

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

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

like image 69
jheddings Avatar answered Sep 20 '22 07:09

jheddings


There is no way to do a redirect based on if javascript is disabled. Why not do the opposite - redirect if javascript is enabled?

<script>
   window.location = "...";
</script>
like image 30
Daniel A. White Avatar answered Sep 22 '22 07:09

Daniel A. White