zoukankan      html  css  js  c++  java
  • Window Location

    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:

    document.write(location.href);

    以上代码输出为:

    http://i.cnblogs.com.cn/js/js_window_location.asp

    Window Location Pathname

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

    实例

    返回当前URL的路径名。

    document.write(location.pathname);

    以上代码输出为:

    /js/js_window_location.asp

    Window Location Assign

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

    实例

    加载一个新的文档:

    <html>
    <head>
    <script>
    function newDoc()
      {
      window.location.assign("http://www.w3school.com.cn")
      }
    </script>
    </head>
    <body>
    
    <input type="button" value="加载新文档" onclick="newDoc()">
    
    </body>
    </html>
  • 相关阅读:
    resourceTree PuTTY/Plink
    error: src refspec 202110221_v1_master does not match any error: failed to push some refs to 'https://gitee.com/simadongyang/m9v1.0'
    go笔记10
    go协程池
    go笔记08
    go笔记06
    go笔记04
    go笔记03
    Git常用命令一
    ajax调用实例
  • 原文地址:https://www.cnblogs.com/Strong-stone/p/9707462.html
Copyright © 2011-2022 走看看