码迷,mamicode.com
首页 > Web开发 > 详细

JS浏览器对象-Location对象

时间:2016-08-10 14:14:05      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

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>

其他方式类似。

JS浏览器对象-Location对象

标签:

原文地址:http://www.cnblogs.com/UniqueColor/p/5756416.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!