zoukankan      html  css  js  c++  java
  • location对象

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

    Location 对象是 Window 对象的一个部分,可通过 window.location 属性来访问。

    属性描述IEFO
    hash 设置或返回从井号 (#) 开始的 URL(锚)。 4 1 9
    host 设置或返回主机名和当前 URL 的端口号。 4 1 9
    hostname 设置或返回当前 URL 的主机名。 4 1 9
    href 设置或返回完整的 URL。 4 1 9
    pathname 设置或返回当前 URL 的路径部分。 4 1 9
    port 设置或返回当前 URL 的端口号。 4 1 9
    protocol 设置或返回当前 URL 的协议。 4 1 9
    search 设置或返回从问号 (?) 开始的 URL(查询部分)。 4 1 9

    例子:

    document.write(location.href + "<br />");//http://localhost/smarty/fpage.php?p=6
    document.write(location.host + "<br />");//localhost:8080
    document.write(location.hostname + "<br />");//localhost
    document.write(location.hash + "<br />");//#dada
    document.write(location.search + "<br />");//?p=6
    document.write(location.pathname + "<br />");// /smarty/fpage.php
    document.write(location.protocol + "<br />");//http:
    document.write(location.port + "<br />");//8080

    学透前端行业所有技术,玩遍北京周边所有城市。然后我会回到那个生我养我的地方,因为有亲人的地方才是家。
  • 相关阅读:
    第五章 Internet协议
    第四章 地址解析协议
    Learn the shell
    Linux学习前的准备
    第三章 链路层
    第二章 Internet 地址结构
    后台数据导出为Excel
    C#开发客户端、JAVA和tomcat开发服务端
    Java基础
    C++学习笔记--(1)
  • 原文地址:https://www.cnblogs.com/snowinmay/p/3174468.html
Copyright © 2011-2022 走看看