url对象 Location




属性 描述
href 设置或返回 URL 地址
pathname 设置或返回 URL 路径
search 设置或返回 URL 参数
hash 设置或返回 URL 的 锚
hostname 设置或返回 URL 域名
port 设置或返回 URL 端口号
host 设置或返回 URL 域名 和 端口号
protocol 设置或返回 URL 协议
方法 描述
assign()

加载新文档

示例:location.assogn("http://www.liboke.cn")

replace()

替换当前文档(不能使用浏览器后退)

示例:location.assogn("http://www.liboke.cn")

reload() 重新加载(无参)

示例:

var s = location.href;