zoukankan      html  css  js  c++  java
  • JS浏览器对象-Location对象

    1、返回web主机的域名

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta charset="UTF-8">
     5 <title>uvi</title>
     6      <link rel="stylesheet" href="style.css" type="text/css">
     7 </head>
     8 <body>
     9   
    10    <button id="btn" onclick="getLoc()">按钮</button>
    11    <p id="ptime"></p>
    12    <script>
    13       function getLoc(){
    14           //返回web主机的域名
    15           document.getElementById("ptime").innerHTML = window.location.hostname;
    16       }
    17    </script>
    18    
    19 </body>
    20 </html>

    2、返回web主机的域名

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta charset="UTF-8">
     5 <title>uvi</title>
     6      <link rel="stylesheet" href="style.css" type="text/css">
     7 </head>
     8 <body>
     9   
    10    <button id="btn" onclick="getLoc()">按钮</button>
    11    <p id="ptime"></p>
    12    <script>
    13       function getLoc(){
    14           //返回web主机的域名
    15           document.getElementById("ptime").innerHTML = window.location.pathname;
    16       }
    17    </script>
    18    
    19 </body>
    20 </html>

    其他方式类似。

  • 相关阅读:
    学习第57天
    学习第56天
    学习第55天
    学习第54天
    学习第53天
    学习第52天
    学习第51天
    学习第50天
    MVVM模式
    css盒模型
  • 原文地址:https://www.cnblogs.com/UniqueColor/p/5756416.html
Copyright © 2011-2022 走看看