user10512966
user10512966

Reputation:

Meta refresh tag not redirecting with noscript tags

I have a <noscript> tag with a meta refresh in it, but when I turn off the browsers javascript, it doesn’t redirect. Here is my code:

<noscript>
<meta http-equiv="refresh" content="0; url=http://mysite.tld/javascript-disabled.html" />
</noscript>

here is my code after the meta tag, and before it:

 <html>
 <head>
<noscript>
<meta http-equiv="refresh" content="0; url=http://mysite.tld/javascript-disabled.html" />
</noscript>
</html>
</head>

This is in a PHP file so I do have php script as follows, if that is interfering:

<?php
 echo "window.alert('test')";
?>

I cant use php header to redirect, like I know is possible, because headers are already called in header.php

I also tried:

<?php
 echo "<noscript>
<meta http-equiv="refresh" content="0; url=http://mysite.tld/javascript-disabled.html" />
</noscript>";
?>

But that causes a php error output.

Upvotes: 1

Views: 2101

Answers (2)

ROLO
ROLO

Reputation: 1

The error with the html line is that you have the <\head> closing tag after the <\html> closing tag. It should be the other way.

Upvotes: -1

A. Meshu
A. Meshu

Reputation: 4148

The error cause by the quote. Try change it to:

<?php
 echo "<noscript>
<meta http-equiv='refresh' content='0; url=http://mysite.tld/javascript-disabled.html' />
</noscript>";
?>

But i'm dought if this will work.

A diffrent approach will be to create a non-javascript page and use javascript to redirect. Something like:

window.location.assign("jsenable.html")

Good luck!

Upvotes: 0

Related Questions