self.location.href=”/url” 当前页面打开URL页面
location.href=”/url” 当前页面打开URL页面
windows.location.href=”/url” 当前页面打开URL页面,前面三个用法相同。
this.location.href=”/url” 当前页面打开URL页面
parent.location.href=”/url” 在父页面打开新页面
top.location.href=”/url” 在顶层页面打开新页面
window.location.href=window.location.href;和window.location.Reload()和都是刷新当前页面。
区别在于是否有提交数据。
当有提交数据时,window.location.Reload()会提示是否提交,
window.location.href=window.location.href;则是向指定的url提交数据。
个人简单代码,在当前页面跳转
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function go(){
location.href = "http://www.baidu.com";
}
</script>
</head>
<body>
<button onclick="go()">跳转</button>
</body>
</html>
本文介绍了使用JavaScript进行网页导航及刷新的各种方法,包括利用location.href和window.location.href属性实现页面跳转与刷新,并展示了简单的代码实例。
898

被折叠的 条评论
为什么被折叠?



