Location replace() 方法

定義和用法
replace() 方法可用一個新文檔取代當前文檔。
語法
location.replace(newURL)
瀏覽器支持
所有主要瀏覽器都支持 replace() 方法
實例
實例
使用 replace() 方法來替換當前文檔:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<script>
function replaceDoc(){
window.location.replace("http://m.o2fo.com")
}
</script>
</head>
<body>
<input type="button" value="載入新文檔替換當前頁面" onclick="replaceDoc()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<script>
function replaceDoc(){
window.location.replace("http://m.o2fo.com")
}
</script>
</head>
<body>
<input type="button" value="載入新文檔替換當前頁面" onclick="replaceDoc()">
</body>
</html>
嘗試一下 ?

更多建議: