本文地址:http://www.cnblogs.com/veinyin/p/7608328.html
1 属性名
-
-
hash: 返回 URL 中的 hash,# 后跟 0 或多个字符
-
host: 返回服务器名称和端口号
-
hostname:返回不带端口号的服务器名称
-
href: 返回当前加载页面的完整 URL
-
pathname: 返回 URL 中的目录和文件名
-
port: 返回 URL 中指定端口号,若无则返回空字符串
-
protocal: 返回页面使用的协议 http: 或 https:
-
search: 返回 URL 的查询字符串,以问号开头
-
2 位置操作
1 location.assign("http://www.xxx.com"); 2 3 //打开该 URL 并在历史记录中添加一条记录
以下两句语句与上面语句效果相同
1 window.location = "http://www.xxx.com"; 2 3 location.href = "http://www.xxx.com"; //最常用
- 重新加载
1 location.reload(); //从缓存中加载 2 3 location.reload(true); //从服务器中加载