Location replace() 方法
定义和用法
replace() 方法可用一个新文档取代当前文档。
语法
浏览器支持
![Internet Explorer Internet Explorer](/jiaocheng/img/bubuko-jiaocheng-f3a6d480-8791-4778-91a5-df56b541a5cc.gif)
![Firefox Firefox](/jiaocheng/img/bubuko-jiaocheng-d8de354b-8846-4d50-b1c8-96cb95308787.gif)
![Opera Opera](/jiaocheng/img/bubuko-jiaocheng-d5769a74-c880-464f-9ff2-110d1ec61e01.gif)
![Google Chrome Google Chrome](/jiaocheng/img/bubuko-jiaocheng-ef734143-ba33-4c12-9427-a6d88b5a244a.gif)
所有主要浏览器都支持 replace() 方法
实例
使用 replace() 方法来替换当前文档:
<html>
<head>
<script>
function replaceDoc()
{
window.location.replace("http://www.bubuko.com")
}
</script>
</head>
<body>
<input type="button" value="Replace document"
onclick="replaceDoc()">
</body>
</html>