这两个元标记的等效项是什么:
<meta http-equiv="refresh" content="0; URL=http://www.example.com/">
<meta http-equiv="refresh" content="35; URL=http://www.example.com/">
在 JavaScript 中?
最佳答案
如果您只需要刷新,可以使用window.location.reload()
。
如果您需要它在 35 秒后触发,请使用 setTimeout(function() { window.location.reload(); }, 35000);
要重定向到另一个页面,您可以使用 window.location.replace('http://www.example.com')
确保浏览器后退按钮跳过上一页,或者window.location = 'http://www.example.com'
以保留浏览器历史记录。
关于Javascript 相当于 http-equiv 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37598988/