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,点击取消返回false
  • window.prompt():提示框。点击确定返回文本框的值,点击取消返回null
  • window.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 = URLwindow.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

最新文章

  1. Can't connect to MySQL server on localhost (0)
  2. Unity手游之路<八>自动寻路Navmesh之入门
  3. my first go
  4. 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
  5. JAVA Builder模式构建MAP/LIST的示例
  6. 使用 Python 抓取欧洲足球联赛数据
  7. iis access denied, you do not have permission.
  8. 对象不支持“attachEvent”属性或方法的解决办法
  9. javascript之DOMReady
  10. mysql应用技巧
  11. Eclipse扩展点
  12. SVN的项目管理
  13. 五、oracle 表的管理
  14. 听翁恺老师mooc笔记(13)--类型定义和联合
  15. Go的安装
  16. Nginx常用的平滑重启
  17. JAVA8之函数式接口
  18. Windows7下安装python3.6.3
  19. Django TypeError: isinstance() arg 2 must be a type or tuple of types
  20. (转)Java并发编程:线程池的使用方法

热门文章

  1. 【hackerrank】Week of Code 26
  2. BZOJ1596 [Usaco2008 Jan]电话网络 【树形dp】
  3. 【DP】【P1586】四方定理
  4. udhcpd源码分析3--IP租赁管理
  5. array_pop 剔除最后一个数组元素
  6. web.xml中出现<servlet-name>default</servlet-name>是什么意思?
  7. Java设计模式の适配器模式
  8. Spring实战第一部分总结
  9. IntelliJ IDEA 热加载
  10. Jenkenis报错:该jenkins实例似乎已离线[转]