BOM

BOM

BOM即 浏览器对象模型(Browser Object Model)

Window(窗口)

1)window对象在页面加载后自动创建,可用于获取文档显示区域的高度和宽度

2)宽度高度(仅仅是页面的宽):window.innerWidth     window.innerHeight

   外部浏览器的高度和宽度(包括了边框、下拉条等):window.outerWidth  window.outerHeight

3)打开新窗口:window.open("baidu.com");

Navigator(浏览器对象)

浏览器名称: navigator.appName

浏览器版本:navigator.appVersion

浏览器内部代码:navigator.appCodeName

操作系统:navigator.platform

是否允许cookies:navigator.cookieEnabled

用户代理报头:navigator.userAgent

Screen(用户屏幕)

用户屏幕分辨率:screen.width   screen.height

可用区域大小(排除了任务栏大小): screen.availWidth  screen.availHeight

History(历史)

返回上次访问:history.back();

返回上上次:history.go(-2);

location(浏览器地址栏)

刷新当前页面:location.reload();

跳转到另一页面:location.assign("地址");

协议:loaction.protocol

主机名:location.hostname

端口号:location.port

主机加端口号:location.host

访问的路径:location.pathname

锚点:location.hash

弹出框

警告框:window.alert("内容"); 也可直接写作 alert("内容");

确认框:confirm(“提示内容”);

输入框:var str = prompt("请输入");

计时器

只执行一次:setTimeout( functionName, 若干毫秒); //则在若干毫秒之后开始执行functionName函数

不停执行:var temp = setInterval( functionName, 若干毫秒); //则每隔这么多毫秒就执行一次

终止setInterval的执行:clearInterval( temp );  //通常放在条件语句中,当满足某条件时终止执行

原文地址:https://www.cnblogs.com/zhuqiwei-blog/p/10321169.html