当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > DOM Location 对象
The Location object is an object that can be accessed through the location property of the Window object.
Location对象可通过window对象的location属性访问到。
The Location object contains information about the current URL.
Location对象包含了当前URL的信息
举例: 将用户传送到新的地方/URL
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Property 属性 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
hash | Sets or returns the part of the href property that follows the hash sign (#) 设置或返回href属性中在#符号后面的内容 | 3 | 1 | 2 | |
host | Sets or returns the hostname and port number of the location or URL 设置或返回URL或本地所在的域名以及端口号 | 3 | 1 | 2 | |
hostname | Sets or returns the hostname of the location or URL 设置或返回本地或是URL所在的域名 | 3 | 1 | 2 | |
href | Sets or returns the entire URL 设置或返回完整的URL | 3 | 1 | 2 | |
pathname | Sets or returns the file name or path specified by the location object 设置或返回由location对象指定的file名称或是路径 | 3 | 1 | 2 | |
port | Sets or returns the port number associated with the URL 设置或返与URL有关的端口号 | 3 | 1 | 2 | |
protocol | Sets or returns the protocol part of the URL 设置或返回URL部分所使用的协议 | 3 | 1 | 2 | |
search | Sets or returns the part of the href property that follows the question mark (?) 设置或返回href属性里?号之后的内容 | 3 | 1 | 2 |
Method 方法 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
assign("URL") | Loads a new document 加载新的文档 | 4 | 1 | 2 | |
reload() | Reloads the current document 重新载入当前文档 | 4 | 1 | 2 | |
replace("URL") | Replaces the current document with the one specified 用一指定的文档来替换当前的文档 | 4 | 1 | 3 |