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://www.w3cschool.cn")
}
</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://www.w3cschool.cn")
}
</script>
</head>
<body>
<input type="button" value="载入新文档" onclick="newDoc()">
</body>
</html>
尝试一下 »

更多建议: