location对象
2025年4月30日小于 1 分钟
示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>location对象</title>
</head>
<body>
<button>跳转1</button>
<button>跳转2</button>
<br/><br/>
<hr/>
<input type="text">
<input type="text">
<button>刷新</button>
<button>强制刷新</button>
<script type="text/javascript">
var buts=document.getElementsByTagName('button');
//页面跳转
//使用属性
buts[0].onclick=function()
{
location.href="./1name01.html";
}
//使用方法 注意:使用方法时 没有历史记录 无法返回
buts[1].onclick=function()
{
location.replace('./1name01.html');
}
//页面刷新
buts[2].onclick=function()
{
location.reload();
}
//页面强制刷新
buts[3].onclick=function()
{
location.reload(true);
}
</script>
</body>
</html>