BOM

作者: 小飞侠zzr | 来源:发表于2017-10-18 21:35 被阅读0次

Browser 对象

Window 对象

Window 对象表示浏览器中打开的窗口。
如果文档包含框架(frame 或 iframe 标签),浏览器会为 HTML 文档创建一个 window 对象,并为每个框架创建一个额外的 window 对象。

屏幕快照 2017-10-18 下午9.13.31.png
屏幕快照 2017-10-18 下午9.13.40.png

confirm带确定和取消的弹框
prompt 带有输入框的弹框
open() 打开新的窗口
四个参数 1.url 要打开窗口的地址
2. target 和 a 标签的一样
3. 窗口特征 可以改变新打开的窗口的样式
4. 是否用新地址替换当前的历史记录 true 替换 false 不替换 生成新的记录
对新窗口的操作
moveBy()在原有的基础上移动
moveTo() 移动到制定坐标 和原来的没有关系
resizeBy() 按照指定的像素调整 窗口的大小
resizeTo() 调整到制定的大小
close();关闭窗口

Navigator 对象

Navigator 对象包含有关浏览器的信息。

//返回浏览器的代码名。
document.write("<p>CodeName: ");
document.write(navigator.appCodeName + "</p>");
console.log(navigator.appCodeName);
// 返回浏览器的次级版本。
document.write("<p>MinorVersion: ")
document.write(navigator.appMinorVersion + "</p>")
console.log(navigator.appMinorVersion);
// 返回浏览器的名称。
document.write("<p>Name: ")
document.write(navigator.appName + "</p>")
// 返回浏览器的平台和版本信息。
document.write("<p>Version: ")
document.write(navigator.appVersion + "</p>");
// 返回当前浏览器的语言。
document.write("<p>BrowserLanguage: ")
document.write(navigator.browserLanguage + "</p>")
// 返回指明浏览器中是否启用 cookie 的布尔值。
document.write("<p>CookieEnabled: ")
document.write(navigator.cookieEnabled + "</p>")
// 返回浏览器系统的 CPU 等级。
document.write("<p>CPUClass: ")
document.write(navigator.cpuClass + "</p>")
// 返回指明系统是否处于脱机模式的布尔值。
document.write("<p>OnLine: ")
document.write(navigator.onLine + "</p>")
// 返回运行浏览器的操作系统平台。
document.write("<p>Platform: ")
document.write(navigator.platform + "</p>")
// 返回 OS 使用的默认语言。
document.write("<p>SystemLanguage: ")
document.write(navigator.systemLanguage + "</p>")
// 返回由客户机发送服务器的 user-agent 头部的值。
document.write("<p>UserAgent: ")
document.write(navigator.userAgent + "</p>")
// 返回 OS 的自然语言设置
document.write("<p>UserLanguage: ")
document.write(navigator.userLanguage + "</p>")
// javaEnabled() 规定浏览器是否启用 Java。
// taintEnabled() 规定浏览器是否启用数据污点 (data tainting)。

Screen 对象

Screen 对象包含有关客户端显示屏幕的信息。

// availHeight 返回显示屏幕的高度 (除 Windows 任务栏之外)。
document.write("<p>Available Height: ")
document.write(screen.availHeight + "</p>")
// availWidth 返回显示屏幕的宽度 (除 Windows 任务栏之外)。
document.write("<p>Available Width: ")
document.write(screen.availWidth + "</p>")
// bufferDepth 设置或返回调色板的比特深度。
document.write("<p>Buffer Depth: ")
document.write(screen.bufferDepth + "</p>")
// colorDepth 返回目标设备或缓冲器上的调色板的比特深度。
document.write("<p>Color Depth: ")
document.write(screen.colorDepth + "</p>")
// deviceXDPI 返回显示屏幕的每英寸水平点数。
document.write("<p>Device XDPI: ")
document.write(screen.deviceXDPI + "</p>")
// deviceYDPI 返回显示屏幕的每英寸垂直点数。
document.write("<p>Device YDPI: ")
document.write(screen.deviceYDPI + "</p>")
// fontSmoothingEnabled 返回用户是否在显示控制面板中启用了字体平滑。
document.write("<p>FontSmoothingEnabled: ")
document.write(screen.fontSmoothingEnabled + "</p>")
// height 返回显示屏幕的高度。
document.write("<p>Height: ")
document.write(screen.height + "</p>")
// logicalXDPI 返回显示屏幕每英寸的水平方向的常规点数。
document.write("<p>Logical XDPI: ")
document.write(screen.logicalXDPI + "</p>")
// logicalYDPI 返回显示屏幕每英寸的垂直方向的常规点数。
document.write("<p>Logical YDPI: ")
document.write(screen.logicalYDPI + "</p>")
// pixelDepth 返回显示屏幕的颜色分辨率(比特每像素)
document.write("<p>Pixel Depth: ")
document.write(screen.pixelDepth + "</p>")
// updateInterval 设置或返回屏幕的刷新率。
document.write("<p>Update Interval: ")
document.write(screen.updateInterval + "</p>")
// width 返回显示器屏幕的宽度。
document.write("<p>Width: ")
document.write(screen.width + "</p>")

History 对象

History 对象包含用户(在浏览器窗口中)访问过的 URL。
History 对象是 window 对象的一部分,可通过 window.history 属性对其进行访问。

History 对象属性 length 返回浏览器历史列表中的 URL 数量。
// History 对象方法
// back() 加载 history 列表中的前一个 URL。
// forward() 加载 history 列表中的下一个 URL。
// go() 加载 history 列表中的某个具体页面。

相关文章

网友评论

    本文标题:BOM

    本文链接:https://www.haomeiwen.com/subject/sgtyuxtx.html