0

I have a file called test.php with the following code.

<!DOCTYPE HTML>
<html>
<head>

<noscript>

<style>

html {
    display:none;
}

</style>

<meta http-equiv="refresh" content="0; url=test2.php" />

</noscript>

</head>
<body>
JavaScript is enabled
</body>
</html>

When I turn off javascript, and refresh the page in Chrome nothing happens. But When I refresh the page again, I'm redirected to test2.php.

How do I force Chrome to redirect to test2.php when I refresh the page the first time?

brewpixels
  • 311
  • 1
  • 5
  • 19
  • 1
    The code you provided doesn't work for me, the `meta` tag should not be inside the `noscript` tag. When I put it outside the `noscript` tag it worked. – Abozanona Mar 06 '16 at 17:13
  • I only want to redirect to test2.php when javascript is turned off. – brewpixels Mar 06 '16 at 17:21
  • Your question has already been answered here: http://stackoverflow.com/questions/2489376/how-to-redirect-if-javascript-is-disabled – Mathijs Mar 06 '16 at 20:46
  • @Mathijs The above link does not provide an answer for this problem. – Abozanona Mar 06 '16 at 21:00
  • The provided code does not work consistent in all browsers because it's not valid. Explained here: http://stackoverflow.com/questions/2489376/how-to-redirect-if-javascript-is-disabled#comment-2482818. An alternatives to your problem could be showing the no-js version first and redirecting if js is enabled. However this is not recommended, because you would be redirecting 99% of your users. – Mathijs Mar 06 '16 at 21:06

0 Answers0