标签:








window.defaultStatus="Welcome to my WebPage!";

//延时调用window.setTimeout(alert("2s later"),2000);window.setTimeout(function(){alert("2s later")},2000);//以上这两句代码的效果是相同的(两秒后弹出提示窗口)var timer=window.setTimeout(alert("2s later"),2000);//声明变量timer来存储延时函数,便于以后对定时操作的删除window.clearTimeout(timer);//清除定时器<h2>ShowCurrentTime</h2><time id="ShowCurrentTime"></time><hr/><button onclick="ShowTime()">ShowTime</button><button onclick="StopTime()">StopTime</button><script>//获取时间并向页面输出function getTime(){var time=document.getElementById(‘ShowCurrentTime‘);if(1){ time.innerHTML="Now:"+(newDate()).toLocaleTimeString();}}//利用window.setTimeout( )显示提示框varIntervalID;functionShowTime(){IntervalID=window.setInterval(getTime,1000); setTimeout("alert(‘隔3秒后弹出此消息框,只显示一次。‘)",3000);//这句代码中的执行代码,会如期在3s后执行/*setTimeout(alert("3s later and it disappears only once!"),2000); *///这条语句其中的执行代码会立即执行而不会等到2s后执行}functionStopTime(){ window.clearInterval(IntervalID)}</script>

<h2>使用location对象</h2><hr/><scripttype="text/javascript"> document.open();//新建HTML文档 document.writeln("location.href="+ window.location.href); document.writeln("<br /> window.location.protocal="+ window.location.protocol); document.writeln("<br /> window.location.host="+ window.location.host); document.writeln("<br /> window.location.pathname="+ window.location.pathname); document.writeln("<br /> window.location.search="+ window.location.search); document.close();//关闭HTML文档</script>
<h2>Location 对象的方法</h2><hr/><buttononclick="window.location.assign(‘http://www.baidu.com‘)">assign</button><p>方法assign结合语句window.location.assign(‘http://www.baidu.com‘)实现百度跳转</p><buttononclick="window.location.reload()">reload</button><p>方法reload结合语句window.location.reload()实现<mark>重新载入当前文档</mark></p><buttononclick="window.location.replace(‘http://www.baidu.com‘)">replace</button><p>方法replace结合语句window.location.replace(‘http://www.baidu.com‘)实现百度跳转,<mark>并且不能够返回</mark></p>

<!--超级链接--><ahref="#"target="_blank">页面</a><!--在新窗口加载页面,可以设置新窗口的相关属性-->window.open("#","name","options")<!--加载页面,并且历史记录中保存相关信息-->document.URL="#"和location.href="a.html"<!--注意replace方法加载页面,在浏览器记录中不保存相关网页信息-->location.replace("#")和location.assign("#")
<script> document.open(); document.write("屏幕宽度是:"+ window.screen.width +"<br/>"); document.write("屏幕高度是:"+ window.screen.height +"<br/>"); document.write("屏幕色深是:"+ window.screen.colorDepth +"<br/>"); document.write("屏幕可用宽度是:"+ window.screen.availWidth +"<br/>");//可用高度是除去任务栏以后的高度 document.write("屏幕可用高度是:"+ window.screen.availHeight +"<br/>"); document.close();</script>
浏览器对象模型(BOM,Browser Object Model)
标签:
原文地址:http://www.cnblogs.com/Jener/p/5939734.html