美文网首页
window.location详解

window.location详解

作者: Love小六六 | 来源:发表于2017-06-19 19:05 被阅读0次

URL为统一资源定位符,对于如下url
http://www.php230.com:80/fisker/post/0703/window.location.html?ver=1.0&id=6#imhere

  • window.location.href
    返回整个URl字符串(在浏览器中就是完整的地址栏)

  • window.location.protocol
    返回URL 的协议部分,http

  • window.location.host
    返回URL 的主机部分,www.php230.com

  • window.location.port
    返回URL 的端口部分

  • window.location.pathname
    返回URL 的路径部分(就是文件地址),:/fisker/post/0703/window.location.html

  • window.location.search
    查询(参数)部分,?ver=1.0&id=6

  • window.location.hash
    锚点,#imhere

Tips
参数只能放到hash前,#后的参数用location.search是查询不到的

相关文章

网友评论

      本文标题:window.location详解

      本文链接:https://www.haomeiwen.com/subject/oklnqxtx.html