我在 html 页面上有以下代码:
<script type="text/javascript">
<!--
window.location.replace("http://www.example.com/");
-->
</script>
和
<meta http-equiv="refresh" content="0;url=http://www.example.com/" >
在 Google Chrome 上,它加载此页面,然后重定向到 example.com,而在我测试过的其他浏览器(IE 和 Firefox)上,它不会加载此 HTML 页面(此特定代码所在的页面),但直接显示example.com
谁能告诉我我的代码有什么问题以及改进它的任何建议,以便它也能在 Google Chrome 上运行。
谢谢
最佳答案
尝试
<script type="text/javascript">
<!--
document.location="http://www.example.com/";
-->
</script>
关于Google Chrome 上的 JavaScript 重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4699714/