js的bom对象

bom(broswer object model)

浏览器对象模型

1.navigator对象 获取客户机的信息(也就是浏览器的信息)

使用navagator对象的appName()属性

2.screen对象  获取屏幕的信息(如屏幕的高度和宽度)

3.location对象 获取当前请求的url地址

使用location对象的href属性


<html>
   <head>
    <title>html示例</title>
   </head>
   <body >
		<input type="button" value="tiaozhuan" onclick="href1()">
   </body>
   <script type="text/javascript">
   		function href1(){
				alert("aaaa");
			}
		document.write("<hr/>");
   		//navigator对象获取浏览器信息
   		document.write(navigator.appName);
		document.write("<br/>");
		document.write("<hr/>");
		//location对象获取当前请求的url
		document.write(location.href);
		
   </script>
</html>

4.history对象(用于获取请求url的历史纪录)

演示方法:

创建一个三个页面,第一个页面为a.html,然后超链接到b.html

创建b.html超链接到c.html,创建c.html

history.back();到访问的上一个页面

history.forward();到访问的下一个页面

a.html

<html>
   <head>
    <title>html示例</title>
   </head>
   <body>
			
		<h1>AAAAAAAAAAAAAAA</h1>
		<a href="b.html">AAAA</a>
		<script type="text/javascript">
		</script>
   </body>
   
</html>

 b.html


<html>
   <head>
    <title>html示例</title>
   </head>
   <body>
		<input type="button" value="back" onclick="back1()"></input>
		<br/>
		<input type="button" value="forward" onclick="next1()"></input>
		
		<h2>BBBBBBBBBBBBBBBB</h2>
		<a href="c.html">BBBB</a>
		<script>
			function back1(){
					history.back();
				}
			function next1(){
					history.forward();
				}
		</script>
   </body>
</html>

c.html


<html>
   <head>
    <title>html示例</title>
   </head>
   <body>
		
			<h1>CCCCCCCCCCCCCCCC<h1>
		<script>
		</script>
   </body>
</html>

猜你喜欢

转载自blog.csdn.net/ll123c/article/details/88878256