首页 > Web开发 > 详细

JS浏览器对象-Location对象

时间:2016-08-10 14:12:33      阅读:233      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!