天天看点

JavaScript基础知识之——Location 对象详解

属性

描述

<a href="http://www.5idev.com/p-javascript_location_hash.shtml">location.hash</a>

设置或取得 URL 中的锚

<a href="http://www.5idev.com/p-javascript_location_host.shtml">location.host</a>

设置或取得 URL 中主机(包括端口号)

<a href="http://www.5idev.com/p-javascript_location_hostname.shtml">location.hostname</a>

设置或取得 URL 中的主机名

<a href="http://www.5idev.com/p-javascript_location_href.shtml">location.href</a>

设置或取得完整 URL(页面重定向应用)

<a href="http://www.5idev.com/p-javascript_location_pathname.shtml">location.pathname</a>

设置或取得 URL 中的路径

<a href="http://www.5idev.com/p-javascript_location_port.shtml">location.port</a>

设置或取得 URL 中的端口号

<a href="http://www.5idev.com/p-javascript_location_protocol.shtml">location.protocol</a>

设置或取得 URL 使用的协议

<a href="http://www.5idev.com/p-javascript_location_search.shtml">location.search</a>

设置或取得 URL 中的查询字串(一般是 ? 符号后面的内容)

继续阅读