[英]Pass JS variable into meta tag http-equiv=refresh into url field
Suppose my url is http://example.com#example.org i want to redirect my current tab "example.com" after 5 sec to query parameter "example.org" 假设我的网址是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>
Instead of using a meta tag to refresh, you should just use Javascript with a timeout to handle the redirect instead. 而不是使用meta标记刷新,您应该只使用带有超时的Javascript来处理重定向。 A metatag cannot get a value passed in from Javascript using the approach you have.
元标记无法使用您使用的方法从Javascript传递值。
<script type="text/javascript">
setTimeout(function() {
window.location.href = window.location.hash.substr(1);
}, 5000);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.