Location assign() 方法

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

更多建議: