js学习第4天:BOM
2019-11-27 本文已影响0人
mapg
BOM(Brower Object Model)浏览器对象模型
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<script type="text/javascript">
//=========window=========== //
function tesConfirm(){
var rs = window.confirm("是否退出");
if (rs) {
window.alert("88")
window.close();
} else{
window.alert("舍不得")
}
}
function testPromp(){
var res = window.prompt("请输入密码");
alert(res);
}
//偏移
function testMoveBy(){
window.moveBy(50,50);
}
//跳转
function testMoveTo(){
window.moveTo(0,250);
}
//增加
function testResizeBy(){
window.resizeBy(250,250);
}
//
function testResizeTo(){
window.resizeTo(300,300);
}
function testScrollBy(){
window.scrollBy(150,50);
}
function testScrollTo(){
window/scrollTo(100,100);
}
//打开一个新窗口加载网页地址
function testOpen(){
window.open("http://www.baidu.com","name:baidu","left=20,top=30,width=300,location=no,toolbar=no,status=no,resizable=no");
}
//计时器
var count = 0;
function getDate(){
var d =new Date();
count++;
if (count>5){
window.clearInterval(d);
//alert("时间到了");
return;
}else{
}
document.getElementById("gtTime").innerHTML = d;
}
var t = window.setInterval("getDate()",1000);
//=========document screen navigtor ===========//
document.write("location.hostname: "+location.href+ "<br/>");
document.write("location.hostname: "+location.hostname+ "<br/>");
document.write("location.host: "+location.host+ "<br/>");
document.write("location.port: "+location.port+ "<br/>");
document.write("location.protocol: "+location.protocol+ "<br/>");
document.write("screen.availHeight: " +screen.availHeight+ "<br/>");
document.write("screen.availWidth: " +screen.availWidth+ "<br/>");
document.write("screen.colorDepth: " +screen.colorDepth+ "<br/>");
document.write("navigator.appCodeName: " + navigator.appCodeName+ "<br/>");
document.write("navigator.appMinorVersion: " +navigator.appMinorVersion+ "<br/>");
document.write("navigator.platform: " + navigator.platform+ "<br/>");
document.write("navigator.useAgent: " +navigator.useAgent+ "<br/>");
document.write("navigator.cookieEnabled: " +navigator.cookieEnabled+ "<br/>");
document.write("location.hostname: "+location.href+ "<br/>");
document.write("location.hostname: "+location.hostname+ "<br/>");
document.write("location.host: "+location.host+ "<br/>");
document.write("location.port: "+location.port+ "<br/>");
document.write("location.protocol: "+location.protocol+ "<br/>");
</script>
<body>
第二个页面:
<!-- ========== history ============ -->
<a href="page03.html">第三个页面</a>
<a href="javascript:history.back()">返回上一页</a>
<a href="javascript:history.forward()">向前一页</a>
<a href="javascript:history.go(-1)">返回上一页</a>
<a href="javascript:history.go(1)">向前一页</a>
<input type="button" value="confirm" onclick="tesConfirm()"/>
<input type="button" value="prompt" onclick="testPromp()"/>
<input type="button" value="moveBy" onclick="testMoveBy()"/>
<input type="button" value="moveTo" onclick="testMoveTo()"/>
<input type="button" value="resizeBy" onclick="testResizeBy()"/>
<input type="button" value="resizeTo" onclick="testResizeTo()"/>
<input type="button" value="scrollBy" onclick="testScrollBy()"/>
<input type="button" value="scrollTo" onclick="testScrollTo()"/>
<input type="button" value="open" onclick="testOpen()"/>
<div id="gtTime"></div>
<!-- 羽格式化 -->
<pre>
羽化格式信息
</pre>
</body>
</html>