window对象:浏览器的实例
location对象:提供当前窗口中加载文档的信息
以 foouser:barpass@www.wrox.com:80/Wiley/?q=ja… 为例: 1.location.hash: "#contents" url散列值,#号后面的的值
2.location.host: "www.wrox.com:80" 服务器名和端口号
3.location.href: "foouser:barpass@www.wrox.com:80/Wiley/q=jac…" 完整url
4.location.port: "80" 端口号
5.location.search: "?q=jacascript" url查询的字符串
6.location操作地址的方法:
(1)assign:传入一个url location.assign("ww.wrox.com")
(2)window.href="ww.wrox.com"
(3)window.location="ww.wrox.com"
上述方法都会使得浏览器历史记录增加相应的记录,如果不希望增加历史记录可以使用window.replace()方法,除了修改hash,修改location的任意属性都会导致页面重新加载url,
navigator对象
screen对象
history对象:当前窗口首次使用以来用户的导航历史记录
history.go(number):number为正值表示前进,负值表示后退,参数也可以是字符串
history.back()和history.forward()分别也表示后退和前进
history.length:表示历史记录中的条目,如果history.length === 1表示这是第一个页面