微智科技网
您的当前位置:首页js中实现页面跳转的方法

js中实现页面跳转的方法

来源:微智科技网
<html>
<head>
<script language="javascript"><!--
    
    function old_page()
    {
        window.location = "http://www.baidu.com"
    }
    function replace()
    {
        window.location.replace("http://www.baidu.com")
    }
    function new_page()
    {
        window.open("http://www.baidu.com")
    }
// --></script>
</head>
<body>
<input type="button" οnclick="new_page()" value="new_page"/>
<BR />
<input type="button" οnclick="old_page()" value="old_page"/>
<BR />
<input type="button" οnclick="replace()" value="replace"/>
</body>
window.location和window.open的区别

window.location = "http://www.baidu.com" 跳转后有后退功能

window.location.replace("http://www.baidu.com") 跳转后没有后退功能

window.open("http://www.baidu.com") 要新的窗口打开链接


本人亲自测试 :window.location.replace 例如Index 和Index2 页面,从Index 页面到Index2页面后在进行后退的时候 可以 把来自
Index2的的返回挡在Index2 页面,不返回Index 页面

转载自:https:///xia9527/article/details/7635054

因篇幅问题不能全部显示,请点此查看更多更全内容