Window对象、Window 的Screen属性、Window Location、Window.history、Window.navigator的属性和方法及含义


前言

本文简单的介绍了JS中的BOM下的对象的方法以及属性


Window对象

  • window.innerHeight - 浏览器窗口的内高度(以像素计)
  • window.innerWidth - 浏览器窗口的内宽度(以像素计)
  • window.open(名称,路径,属性) - 打开新窗口
  • window.close() - 关闭当前窗口
  • window.moveTo() -移动当前窗口
  • window.resizeTo() -重新调整当前窗口

Window 的Screen属性

  • screen.width - 属性返回以像素计的访问者屏幕宽度。
  • screen.height - 属性返回以像素计的访问者屏幕的高度。
  • screen.availHeight - 属性返回访问者屏幕的高度,以像素计,减去诸如窗口工具条之类的界面特征
  • screen.availWidth - 属性返回访问者屏幕的宽度,以像素计,减去诸如窗口工具条之类的界面特征。
  • screen.colorDepth - 属性返回用于显示一种颜色的比特数。
  • screen.pixelDepth - 属性返回屏幕的像素深度。

Window Location

  • window.location.href - 返回当前页面的 href (URL)
  • window.location.hostname - 属性返回(当前页面的)因特网主机的名称
  • window.location.pathname - 属性返回当前页面的路径名。
  • window.location.protocol - 属性返回页面的 web 协议
  • window.location.assign() - 方法加载新文档。
  • window.location.port - 属性返回(当前页面的)互联网主机端口的编号。

window.history

window.history 对象包含浏览器历史

  • history.back() - 等同于在浏览器点击后退按钮
  • history.forward() - 等同于在浏览器中点击前进按钮

window.navigator

window.navigator 对象包含有关访问者的信息。

  • Navigator.cookieEnabled 属性返回 true,如果 cookie 已启用,否则返回 false:
  • navigator.appName 属性返回浏览器的应用程序名称
  • navigator.appCodeName 属性返回浏览器的应用程序代码名称:
  • navigator.product 属性返回浏览器引擎的产品名称:
  • navigator.appVersion 属性返回有关浏览器的版本信息:
  • navigator.userAgent 属性返回由浏览器发送到服务器的用户代理报头(user-agent header):
  • navigator.platform 属性返回浏览器平台(操作系统):
  • navigator.language 属性返回浏览器语言:
  • navigator.onLine 属性返回 true,假如浏览器在线:
  • navigator.javaEnabled() 方法返回 true,如果 Java 已启用:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涵仔ovo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值