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>

    其他方式类似。

  • 相关阅读:
    教你如何剖析源码
    Java 简介
    java 入门-helloWorld
    linux yum 命令
    Linux vi/vim
    Linux 磁盘管理
    Linux 用户和用户组管理
    Linux 文件与目录管理
    Linux 文件基本属性
    Linux安装Mysql
  • 原文地址:https://www.cnblogs.com/UniqueColor/p/5756416.html
Copyright © 2011-2022 走看看