您的位置:首页 > Web前端 > JavaScript

关于JavaScript的location对象的使用

2015-10-10 10:59 746 查看
代码示例如下:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus?">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>location对象</title>
</head>
<script type="text/javascript">
<!--
/*
掌握:1 href属性
2. reload()方法:重新加载本页面
*/
function fun(){
//window.location.href = "history对象/b.html" ;  //假设b.html文件在你当前目录下的history对象的文件夹下,
//那么通过这条语句,可以直接跳转到b.html页面
window.location = "b.html" ;         //作用同上,只是两种不同的写法
}

function fun1(){
window.location.reload();     //重新加载本页面
}
//-->
</script>
<body>
<input type="button" value="直接去b.html" onclick="fun()">
<input type="button" value="重新加载本页面" onclick="fun1()">
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: