zoukankan      html  css  js  c++  java
  • JS获取当前页面URL的方法

    1.JS获取当前页面URL的方法小结

      ①. document.URL;                           http://localhost:81/Test/1.htm/id/12

      ②. document.location.href;     http://localhost:81/Test/1.htm/id/12

      ③. self.location.href;        http://localhost:81/Test/1.htm/id/12

      ④. document.location        http://localhost:81/Test/1.htm/id/12

      ⑤. top.location.href;          http://localhost:81/Test/1.htm/id/12

      ⑥. parent.document.location;         http://localhost:81/Test/1.htm/id/12

      ⑦. top.location.hostname;              localhost

      ⑧. location.hostname;                    localhost

      ⑨.window.location.protocol;          http

      ①. window.location.host;                localhost:81

      ②.window.location.pathname;        /Test/1.htm/id/12

    哪种代码获取的是url的哪部分内容是不是就一目了然了!!!!!

  • 相关阅读:
    java学习55天2020/8/29
    java学习51天2020/8/25
    java学习55天2020/8/31
    java学习49天2020/8/23
    java学习52天2020/8/26
    java学习48天2020/8/22
    2020.12.05
    2020.12.04
    2020.12.07
    2020.12.03
  • 原文地址:https://www.cnblogs.com/jingmin/p/6528577.html
Copyright © 2011-2022 走看看