Location replace() 方法

定义和用法
replace() 方法可用一个新文档取代当前文档。
语法
location.replace(newURL)
浏览器支持
所有主要浏览器都支持 replace() 方法
实例
实例
使用 replace() 方法来替换当前文档:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>高手教程(study.p2hp.com)</title>
<script>
function replaceDoc(){
window.location.replace("http://study.p2hp.com")
}
</script>
</head>
<body>
<input type="button" value="载入新文档替换当前页面" onclick="replaceDoc()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>高手教程(study.p2hp.com)</title>
<script>
function replaceDoc(){
window.location.replace("http://study.p2hp.com")
}
</script>
</head>
<body>
<input type="button" value="载入新文档替换当前页面" onclick="replaceDoc()">
</body>
</html>
尝试一下 »

点我分享笔记