* BOM:浏览器对象模型
* 介绍:
* window对象:窗口对象,一个页面就具有一个window对象.
* Navigator对象:浏览器对象,用于存储当前浏览器的基本信息.
* Screen对象:屏幕对象,用于存储当前浏览器显示的一些信息,例如:高度、宽度等.
* Location对象:本地对象,用于存储当前浏览器所访问网站的地址信息.
* History对象:历史对象.
* 用于存储当前浏览器所访问过的网站地址信息.
window对象:
属性介绍:
window.location
window.history
window.document
......window对象下的其他对象,都素hi以window对象的属性形式存在。
方法介绍:
window的方法的格式:
window.方法名 或者 直接方法名的形式
1.window.alert()或者alert();
alert("李卫康");
2.window.prompt("参数1","参数2") 参数1主要是提示用户输入框中输入什么信息,参数2为输入框中的默认信息
prompt("请输入用户名!","username");
3.window.confirm();用于显示一个带有指定消息和 OK 及取消按钮的对话框。
var i=confirm("李卫康是好人!");
alert(i)
如果点击确定按钮 返回true..如果点击取消按钮就是false
4.动态显示当前时间
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>02_动态时钟显示.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<div id="show"></div>
</body>
<script type="text/javascript">
//在当前页面中,显示系统的当前时间.
function show(){
//系统当前时间
var datetime=new Date();
document.getElementById("show").innerHTML=datetime;
setTimeout("show()",1000);
}
show();
</script>
</html>
Navigator对象
<script type="text/javascript">
//1 appName属性:浏览器的名称.
alert(navigator.appName);
//2 appVersion属性:返回的4.0内容,表示浏览器内核.
alert(navigator.appVersion)
//3 platform
alert(navigator.platform)
</script>
Location对象
<script type="text/javascript">
//1 127.0.0.1:8000
alert(location.host);
alert(location.hostname);
alert(location.port);
alert(location.href);
</script>