小编use*_*779的帖子

window.location重定向有效,但原始URL未显示在浏览器历史记录中

下面的代码效果很好.这是我的问题:窗口网址重定向,但原始网址未记录在我的浏览器历史记录中.

例如,如果我访问"http://example.com/page1",浏览器就会重定向到"http://example.com/test".但是,我需要访问的原始网址("http://example.com/page1")显示在我的浏览器历史记录中,以便我可以在其他功能中调用它.

在重定向之前,是否有访问原始网址以登录浏览器的历史记录?

<!-- script to enable age verification cookies and ensure people have age checked -->
<script type="text/javascript">
    $(document).ready(function(){
       if (window.location =="http://example.com/home") {//do nothing
       } else {
           window.location = "http://example.com/test";
       }
    });
</script>
Run Code Online (Sandbox Code Playgroud)

javascript jquery redirect window.location browser-history

9
推荐指数
1
解决办法
9207
查看次数