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 = 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