您的位置:首页 > Web前端 > JavaScript

javascript BOM对象 第15节

2015-08-19 13:38 651 查看
<html>
<head>
<title>浏览器对象</title>

<script type="text/javascript">
var  a = 20;//声明变量 函数  对象 属于window对象
//alert(window.a);
function  test () {
alert("window对象函数");

}
//window.test();//函数调用

</script>

</head>
<body>
<div>BOM对象</div>

1.navigator<br/>
<script type="text/javascript">

for ( var name in navigator  )
{
document.write(name ," : " ,navigator[name], "<br/>");
}

</script>

2.screen<br/>
<script type="text/javascript">

for ( var name in screen )
{
document.write(name ," : " , screen[name], "<br/>");
}

</script>

3.history<br/>
<script type="text/javascript">

</script>
<a href="浏览器对象.htm" target="_self">浏览器对象</a>
<input type="button" value="向前" onclick="history.forward()"/><br/>

4.location<br/>
<script type="text/javascript">
document.write("location.host : ", location.host, "<br/>");
document.write("随机数 : ", Math.round(Math.random() * 100), "<br/>");
</script>
<input type="button" value="换页1" onclick="location.href='浏览器对象.htm'"/>
<input type="button" value="换页2" onclick="location='浏览器对象.htm'"/>
<input type="button" value="刷新" onclick="location.reload()"/>
<input type="button" value="替换" onclick="location.replace('内置对象.htm')"/>
<input type="button" value="转向" onclick="location.assign('内置对象.htm')"/>

</body>

</html>


rs:



2.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: