元刷新标签不使用 noscript 标签重定向

Meta refresh tag not redirecting with noscript tags

我有一个带有元刷新的 <noscript> 标签,但是当我关闭浏览器时 javascript,它不会重定向。这是我的代码:

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

这是我在元标记之后和之前的代码:

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

这是在 PHP 文件中,所以我有 php 脚本如下,如果有干扰的话:

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

我不能使用 php header 来重定向,我知道这是可能的,因为 header 已经在 header.php

中调用了

我也试过:

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

但这会导致 php 错误输出。

引用引起的错误。尝试将其更改为:

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

但我不知道这是否可行。

另一种方法是创建非 javascript 页面并使用 javascript 进行重定向。类似于:

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

祝你好运!