zoukankan      html  css  js  c++  java
  • window.location各个属性-笔记

    Location 对象包含有关当前 URL 的信息。

    Location 对象是 window 对象的一部分,可通过 window.Location 属性对其进行访问。

    直接看例子吧

    http://test-hao.ping.com/wap/huo/yiduanshi.html?version=1.0&name=123#number=1

    如果直接

    console.log(window.location);
    

    结果是这样子的:

    protocol: "http:"                             //返回URL协议
    host: "test-hao.ping.com"                     //返回URL的主机名和端口
    hostname: "test-hao.ping.com"           //返回URL的主机名
    port: ""                                      //返回URL服务器使用的端口号
    pathname: "/wap/huo/yiduanshi.html"           //返回URL路径名
    search: "?version=1.0&name=123"               //返回URL的查询部分
    hash: "#number=1"                             //返回URL的锚部分
    href: "http://test-hao.ping.com/wap/huo/yiduanshi.html?version=1.0&name=123#number=1"  //返回完整的URL
    

    解释:

    1:http协议端口号80为默认端口号,如果端口号为80,则返回空。

    2:hash返回的部分为#加上后边的内容。

  • 相关阅读:
    百度诉360案一审宣判索赔1亿判赔70万
    软件设计之状态机
    linux下so获得自己文件位置的路径
    openssh-server
    安卓下查看kmsg内核日志
    Python kmean
    numpy
    HostMonitor监控主机状态
    ubuntu MySQL安装和设置
    Python Post img
  • 原文地址:https://www.cnblogs.com/pengxiangchong/p/12744949.html
Copyright © 2011-2022 走看看