JavaScript中常用的BOM属性
2024-10-20 05:43:12
window
窗口
window.open()
:打开窗口。返回一个指向新窗口的引用。window.close()
:关闭窗口。window.resizeTo()
:调整窗口尺寸到指定值window.resizeBy()
:增加窗口尺寸,增加量为指定值window.moveTo()
:移动窗口window.moveBy()
:移动窗口,坐标增加量为指定值window.innerHeight
:浏览器窗口的内部高度window.innerWidth
:浏览器窗口的内部宽度
计时器
window.setTimeout()
:超时调用window.clearTimeout()
:取消超时调用window.setInterval()
:间歇调用window.clearInterval()
:取消间歇调用
对话框
window.alert()
:警告框window.confirm()
:确认对话框。返回布尔值,点击确定返回true,点击取消返回falsewindow.prompt()
:提示框。点击确定返回文本框的值,点击取消返回nullwindow.print()
:打印对话框window.find()
:查找对话框
location
属性
location.href
:完整URL,如http://www.bnu.edu.cn:8080/path/to/homepage/index.html?name='peter'&age='20'#contents
location.protocol
:协议名,如http:
location.hostname
:服务器名,如www.bnu.edu.cn
location.host
:服务器名及端口号,如www.bnu.edu.cn:8080
location.port
:端口号,如8080
location.pathname
:目录和文件名,如/path/to/homepage/index.html
location.search
:查询字符串,以问好开头,如?name='peter'&age='20'
location.hash
:散列值,即#号后面,如#contents
方法
location.assign()
:打开指定URL,并在历史记录中生成一条记录。等价于location.href = URL
和window.location = URL
。location.replace()
:打开指定URL,但不生成新的历史记录。location.reload()
:重新加载当前页面。默认以最有效的方式加载,可能会请求到缓存。location.reload(true)
:重新加载当前页面,强制从服务器重新加载。
navigator.
navigator.userAgent
:用户代理字符串navigator.plugins
:安装插件信息的数组navigator.onLine
:检测设备在线还是离线
screen
screen.availWidth
:可用的屏幕宽度。以像素计,减去界面特性,比如窗口任务栏。screen.availHeight
:可用的屏幕高度。以像素计,减去界面特性,比如窗口任务栏。screen.width
:屏幕的像素宽度screen.height
:屏幕的像素高度screen.colorDepth
:颜色位数
history
history.go()
:跳转到任意历史记录。- 若传入整数,正数为前进,负数为后退。
- 若传入字符串,则跳转到历史记录中包含该字符串的第一个位置。
history.back()
:后退一页history.forward()
:前进一页history.length
:历史记录的数量。对于窗口中第一个打开的页面而言,其history.length为0。history.pushState()
:历史状态管理。将新的状态信息加入历史状态栈。history.replaceState
:历史状态管理。重写历史状态。
参考自:《JavaScript高级程序设计》、W3school
最新文章
- Can't connect to MySQL server on localhost (0)
- Unity手游之路<;八>;自动寻路Navmesh之入门
- my first go
- Given a compiled machine-language program, which statements in the source language cause the execution of the most machine-language instructions and what is the execution time of these instr
- JAVA Builder模式构建MAP/LIST的示例
- 使用 Python 抓取欧洲足球联赛数据
- iis access denied, you do not have permission.
- 对象不支持“attachEvent”属性或方法的解决办法
- javascript之DOMReady
- mysql应用技巧
- Eclipse扩展点
- SVN的项目管理
- 五、oracle 表的管理
- 听翁恺老师mooc笔记(13)--类型定义和联合
- Go的安装
- Nginx常用的平滑重启
- JAVA8之函数式接口
- Windows7下安装python3.6.3
- Django TypeError: isinstance() arg 2 must be a type or tuple of types
- (转)Java并发编程:线程池的使用方法
热门文章
- 【hackerrank】Week of Code 26
- BZOJ1596 [Usaco2008 Jan]电话网络 【树形dp】
- 【DP】【P1586】四方定理
- udhcpd源码分析3--IP租赁管理
- array_pop 剔除最后一个数组元素
- web.xml中出现<;servlet-name>;default<;/servlet-name>;是什么意思?
- Java设计模式の适配器模式
- Spring实战第一部分总结
- IntelliJ IDEA 热加载
- Jenkenis报错:该jenkins实例似乎已离线[转]