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

    学透前端行业所有技术,玩遍北京周边所有城市。然后我会回到那个生我养我的地方,因为有亲人的地方才是家。
  • 相关阅读:
    Html5结构相关元素
    html5文本元素
    html5全局属性
    元数据元素总结
    千里之行,始于足下
    换个角度思考
    java的权限修饰符
    四则运算
    测量软件使用感受
    JQuery高级
  • 原文地址:https://www.cnblogs.com/snowinmay/p/3174468.html
Copyright © 2011-2022 走看看