1.window對象
<body>
<button id="btn" onclick="btnClick()">按鈕</button>
<script>
//讀取瀏覽器長寬
document.write(window.innerHeight+","+window.innerWidth);
//window的打開關閉
function btnClick(){
//1.跳轉url 2.新窗口名字 3.新窗口屬性
// window.open("newdex.html","windowname","height = 200,width = 200");
window.close();
}
</script>
</body>
2.計時器對象
<body onload="myWin()">
<p id="ptime"></p>
<script>
var mytime = setInterval(function(){
getTime();
},500);
function getTime(){
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("ptime").innerHTML = t;
}
function stopTime(){
clearInterval(mytime);
}
var win;
function myWin(){
alert("hello");
win = setTimeout(function(){myWin()},2000);
}
function stopWin(){
clearTimeout(win);
}
</script>
</body>
3.history對象
<body>
<button onclick="history.go(-1)">後退</button> -1對於後退
</body>
4.location對象
<script>
function btnClick(){
location.assign("http://www.baidu.com");
}
</script>
5.Screen對象