zoukankan      html  css  js  c++  java
  • JavaScript Window Location

    window.location对象用于获得当前页面地址(URL),并把浏览器重定向到新页面。

    Window Location

    window.location对象在编写时可不使用window这个前缀。一些例子:

        location.hostname返回web主机域名

        location.pathname返回返回当前页面的路径和文件名

        location.port返回web主机的端口(80或443)

        location.protocol返回所使用的web协议(http://或https://)

    Window Location Href

    location.href属性返回当前页面的URL

    返回(当前页面的)整个 URL:

    <script>
        document.write(location.href);
    </script>

    http://www.runoob.com/js/js-window-location.html

    Window Location Pathname

    location.pathname属性返回URL的路径名。

    返回当前URL的路径名。

    <script>
        document.write(location.pathname);
    </script>

    /js/js-window-location.html

    Window Location Assign

    location.assign() 方法加载新的文档。

    加载一个新的文档:

    <html>
    <head>
    <script>
    function newDoc()
      {
      window.location.assign("http://www.w3cschool.cc")
      }
    </script>
    </head>
    <body>

    <input type="button" value="Load new document" onclick="newDoc()">

    </body>
    </html>
  • 相关阅读:
    day54
    day53
    CAS客户端整合(四)-- Cacti
    不重新编译安装php模块的方法
    CAS客户端整合(三) Otrs
    CAS客户端整合(二) Zabbix
    CAS客户端整合(一) Discuz!
    [Django笔记] Apache + mod-wsgi 环境部署所遇到的各种问题总结
    Baidu
    Scrapy框架初探
  • 原文地址:https://www.cnblogs.com/Strong-stone/p/10302138.html
Copyright © 2011-2022 走看看