【问题标题】:Meta refresh tag not redirecting with noscript tags元刷新标签不使用 noscript 标签重定向
【发布时间】:2019-04-02 19:17:27
【问题描述】:

我有一个带有元刷新的 <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.php 中调用

我也试过了:

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

但这会导致 php 错误输出。

【问题讨论】:

    标签: javascript php html meta-tags noscript


    【解决方案1】:

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

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

    但我不知道这是否可行。

    另一种方法是创建一个非 JavaScript 页面并使用 JavaScript 进行重定向。类似的东西:

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

    祝你好运!

    【讨论】:

    • 谢谢。我会尽力让你知道。
    猜你喜欢
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 2011-07-14
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2015-04-10
    相关资源
    最近更新 更多