javascript学习笔记:BOM对象(存疑)

来源:互联网 发布:linux中连接本地 编辑:程序博客网 时间:2024/05/20 05:09

HTML文件:

<html><head></head><body><script type="text/javascript" src="jsBOMDemo.js"></script><!--通过点击按钮调用JS中的函数--><input type="button" onclick="ShowCurrentURL()" value="show current url"/><input type="button" onclick="JumpToBaidu()" value="hyperlink button"/><br/><input type="button" onclick="open_a_new_window()" value="open_a_new_window"/><input type="button" onclick="close_window()" value="close_window"/><input type="button" onclick="pushADs()" value="pushADs"/><input type="button" onclick="JumpWithTimeout()" value="setTimeoutDemo"/></body></html>
javascript文件:

//JS中的BOM对象示例,从上往下记录/*//Navigator对象包含了客户机浏览器的信息document.write("navigator.appName:"+navigator.appName+"<br/>");document.write("navigator.appVersion:"+navigator.appVersion+"<br/>");document.write("navigator.userAgent:"+navigator.userAgent+"<br/>");//Screen对象包含了客户机的显示器信息document.write("screen.width:"+screen.width+"<br/>");document.write("screen.height:"+screen.height+"<br/>");//Location对象包含了url等信息document.write("location.href:"+location.href+"<br/>");//定义相关函数与HTML互动function ShowCurrentURL(){alert(location.href);}function JumpToBaidu(){location.href="https://www.baidu.com/";}//Windows对象,能够与浏览器窗口互动.window对象的所有方法前的window前缀均可省略var flag=window.confirm("confirm to delete?");//confirm(),弹出式确认框if(flag)window.alert("you delete something");//alert(),弹出式显示框window.prompt("input your favorate number:","0");//prompt(),弹出式输入框function open_a_new_window(){window.open("https://www.baidu.com/");//open(),打开新窗口,可指定目标}function close_window(){window.close();//close(),关闭当前窗口}*/function pushADs()//存疑{//setInterval(),中断计时器函数,它可以识别第一参数中的代码并执行,函数会返回计时器的一个id,使用clearInterval()清除中断var id_Interval=window.setInterval("alert('AD')",1000);//setTimeout(),倒计时触发器,会返回计时器id,使用clearTimeout()清除倒计时var id_Timeoout=window.setTimeout("clearInterval(id_Interval)",5000);//为什么调试时显示id_Interval未定义?}// function JumpWithTimeout()// {// alert("即将为您跳转到登陆前的页面");//setTimeout(),倒计时触发器,常用于登录后页面跳转,函数同样返回计时器的id// var int=window.setTimeout("location.href='https://www.baidu.com/'",3000);// }



原创粉丝点击