您的位置:首页 > 其它

location

2015-12-28 16:07 330 查看
location
对象表示当前页面的URL信息。例如,一个完整的URL:
http://www.example.com:8080/path/index.html?a=1&b=2#TOP
可以用
location.href
获取。要获得URL各个部分的值,可以这么写:
location.protocol; // 'http'
location.host; // '
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?a=1&b=2'
location.hash; // 'TOP'
要加载一个新页面,可以调用
location.assign()
。如果要重新加载当前页面,调用
location.reload()
方法非常方便。

<a onclick="location.assign('http://www.baidu.com');">加载一个新页面</a>
<a onclick="location.reload();">重新加载当前页面</a>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  信息