一、window对象
1.属性
下面两个现在也慢慢被淘汰了,不经常用了
frames //窗口数组
top //顶级窗口
<html>
<head>
<meta charset="UTF-8" />
<title>index</title>
</head>
<frameset rows="50,*">
<frame src="top.html">
<frameset cols="150,*">
<frame src="left.html" noresize> //边界线不可拖动
<frame src="right.html">
</frameset>
</frameset>
</html>
2.方法
alert();
confirm();
prompt();
setInterval();
clearInterval();
setTimeout();
clearTimeout();
二、navigator浏览器特性
1. 属性
userAgent //更精确的版本
<script>
nav=navigator.userAgent;
ntype=nav.match(/chrome|firefox|trident/i);//分别为谷歌,火狐,IE浏览器
alert(ntype);
</script>
//根据上面代码可以判断当前的浏览器
三、screen屏幕对象
1.属性
availHeight //屏幕有效高
availWidth //屏幕有效宽
height //屏幕高
width //屏幕宽
<html>
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
*{
font-family: 微软雅黑;
}
</style>
</head>
<body>
<h1>aaaaaaaaaaaaaaaaaaaa</h1>
</body>
<script>
sw=screen.width;
sh=screen.height;
saw=screen.availWidth;
sah=screen.availHeight;
document.write(sw+'-'+sh+'-'+saw+'-'+sah);
</script>
</html>
四、history对象
1. 方法:
back() //后退一个历史
forward() //前进一个历史
go(-1) //前进一个历史
test0810.html
<html>
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<div >
<a href="left.html">下一页</a>
</div>
</body>
</html>
left.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<div>
<a href="javascript:" id="aid">返回上一页</a>
</div>
</body>
<script>
aobj=document.getElementById('aid');
aobj.onclick=function(){
history.back();
}
</script>
</html>
五、location地址栏
1.属性
hash //获取url里的锚点#abc
<script>
alert(location.hash);
</script>
host //域名
<html>
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<h1>aaaaaaaaaaaaaaa</h1>
<h1>aaaaaaaaaaaaaaa</h1>
<h1>aaaaaaaaaaaaaaa</h1>
</body>
<script>
alert(location.host);
</script>
</html>
href //当前的url地址
<script>
document.write(location);
document.write("<br>");
document.write(location.href);
</script>
//说明二者等价
pathname //index.html 页面的名称
<script>
alert(location.pathname);
</script>
protocol //协议
<script>
document.write(location.protocol);
</script>
search //参数 ?id=10&name=user1
<script>
alert(location.search);
</script>
2. 方法
reload();
<body>
<div class="main">
<script>
dobj=new Date;
h=dobj.getHours();
m=dobj.getMinutes();
s=dobj.getSeconds();
document.write(h+'-'+m+'-'+s);
</script>
</div>
<p><a href="javascript:" id="aid">刷新</a></p>
</body>
<script>
aobj=document.getElementById('aid');
aobj.onclick=function(){
location.reload();
}
</script>
//刷新当前页面也可以重新获取当前时间