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返回的部分为#加上后边的内容。

  • 相关阅读:
    镜像的上传和下载
    ps 命令
    过滤不合格数据
    云计算5-3-2法则
    Python Django初入门
    python web框架
    BootStrap、EasyUI、JQueryUI
    JS正则
    ngonx FastCGI 相关参数调优
    Windows10远程连接错误-出现身份验证错误
  • 原文地址:https://www.cnblogs.com/pengxiangchong/p/12744949.html
Copyright © 2011-2022 走看看