3rd
09.08
Javascript脚本:Location 对象
Location 对象是 Window 对象的一个部分,可通过 window.location 属性来访问。
举例说下 Location 对象 的属性与方法
- hash:设置或返回从井号 (#) 开始的 URL(锚)
- 网址:http://www.cngothic.com/index.html#head
- 返回:#head
- <script type="text/javascript">
- document.write(location.pathname);
- </script>
- host:设置或返回主机名和当前 URL 的端口号
- 网址:http://www.cngothic.com:3389/index.html
- 返回:www.cngothic.com:3389
- hostname:设置或返回当前 URL 的主机名
- 网址:http://www.cngothic.com:3389/index.html
- 返回:www.cngothic.com
- href:设置或返回完整的 URL
- 网址:http://www.cngothic.com:3389/index.html
- 返回:http://www.cngothic.com:3389/index.html
- pathname:设置或返回当前 URL 的路径部分
- 网址:http://www.cngothic.com/index.html#head
- 返回:/index.html
- port:设置或返回当前 URL 的端口号
- 网址:http://www.cngothic.com:3389/index.html
- 返回:3389
- protocol:设置或返回当前 URL 的协议
- 网址:http://www.cngothic.com:3389/index.html
- 返回:http:
- search:设置或返回从问号 (?) 开始的 URL(查询部分)。
- 网址:http://www.cngothic.com/index.html?id=333
- 返回:?id=333
assign(), host, hostname, href, Javascript脚本, Location 对象, pathname, port, protocol, reload(), replace(), search
Name: Cngothic 













