HTML DOM replace() 方法
定義和用法
replace() 方法可用一個新文檔取代當前文檔。
語法
location.replace(newURL)
說明
replace() 方法不會在 History 對象中生成一個新的記錄。當使用該方法時,新的 URL 將覆蓋 History 對象中的當前記錄。
實例
下面的例子將使用 replace() 方法來替換當前文檔:
<html>
<head>
<script type="text/javascript">
function replaceDoc()
{
window.location.replace("http://www.dbjr.com.cn")
}
</script>
</head>
<body>
<input type="button" value="Replace document" onclick="replaceDoc()" />
</body>
</html>