包含有关当前 URL 的信息
Location 对象是 window 对象的一部分,可通过 window.Location 属性对其进行访问。
一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)
googleIEfirefoxsafarioperatruetruetruetruetruelocation.hash
document.write(location.hash);可读可写的字符串,可设置或返回当前 URL 的主机名称和端口号
googleIEfirefoxsafarioperatruetruetruetruetruelocation.host
document.write(location.host);可读可写的字符串,可设置或返回当前 URL 的主机名
googleIEfirefoxsafarioperatruetruetruetruetruelocation.hostname
document.write(location.hostname);可读可写的字符串,可设置或返回当前显示的文档的完整 URL
googleIEfirefoxsafarioperatruetruetruetruetruelocation.href
document.write(location.href);可读可写的字符串,可设置或返回当前 URL 的路径部分
googleIEfirefoxsafarioperatruetruetruetruetruelocation.pathname
document.write(location.pathname );可读可写的字符串,可设置或返回当前 URL 的端口部分
location.port
document.write(location.port);可读可写的字符串,可设置或返回当前 URL 的协议
googleIEfirefoxsafarioperatruetruetruetruetruelocation.protocol
document.write(location.protocol);可读可写的字符串,可设置或返回当前 URL 的查询部分(问号 ? 之后的部分)
googleIEfirefoxsafarioperatruetruetruetruetruelocation.search
document.write(location.search);加载一个新的文档
googleIEfirefoxsafarioperatruetruetruetruetruelocation.assign(URL)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>zsh</title> <script> function newDoc(){ window.location.assign("http://www.zshgrwz.cn/360") } </script> </head> <body> <input type="button" value="载入新文档" onclick="newDoc()"> </body> </html>用于刷新当前文档
reload() 方法类似于你浏览器上的刷新页面按钮。
如果把该方法的参数设置为 true,那么无论文档的最后修改日期是什么,它都会绕过缓存,从服务器上重新下载该文档。这与用户在单击浏览器的刷新按钮时按住 Shift 健的效果是完全一样。
googleIEfirefoxsafarioperatruetruetruetruetruelocation.reload(Boolean)
可用一个新文档取代当前文档
googleIEfirefoxsafarioperatruetruetruetruetruelocation.replace(newURL)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>zsh</title> <script> function replaceDoc(){ window.location.replace("http://www.runoob.com") } </script> </head> <body> <input type="button" value="载入新文档替换当前页面" onclick="replaceDoc()"> </body> </html>文档内容出自 W3cSchool和菜鸟教程, 如需查看更详细的有关内容 请登录 http://www.w3school.com.cn/ 和 http://www.runoob.com/