【问题标题】:Pass JS variable into meta tag http-equiv=refresh into url field将 JS 变量传递到元标记 http-equiv=refresh 到 url 字段
【发布时间】:2017-12-13 00:32:59
【问题描述】:

假设我的网址是http://example.com#example.org 我想在 5 秒后重定向我当前的标签“example.com”以查询参数“example.org”

<head>
<title></title>

<script type="text/javascript">
var x = window.location.hash.substr(1);
</script>

<meta http-equiv="refresh" content="4;url=x"/>

</head>
<body>
</body>

【问题讨论】:

    标签: javascript html query-string query-parameters


    【解决方案1】:

    您应该只使用带有超时功能的 Javascript 来处理重定向,而不是使用元标记来刷新。元标记无法使用您拥有的方法从 Javascript 获取传入的值。

    <script type="text/javascript">
    setTimeout(function() {
        window.location.href = window.location.hash.substr(1);
    }, 5000);
    </script>
    

    【讨论】:

      猜你喜欢
      • 2012-06-28
      • 1970-01-01
      • 2020-03-29
      • 1970-01-01
      • 2018-02-17
      • 1970-01-01
      • 2014-01-22
      • 1970-01-01
      • 2012-07-19
      相关资源
      最近更新 更多