码迷,mamicode.com
首页 > 其他好文 > 详细

location对象

时间:2016-12-11 22:53:09      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:地址   html   reload   tle   arch   ash   toc   put   新网   

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
 5     <title>location对象</title>
 6     <script>
 7         var str = "<h2>当前地址的相关信息如下</h2>";
 8         str += "完整的URL地址:"+location.href;
 9         alert(location.href);
10         str += "<br>协议:"+location.protocol;
11         str += "<br>主机名:"+(location.host ? location.host :"主机不存在");
12         str += "<br>文件名:"+location.pathname;
13         str += "<br>查询字符串:"+location.search ? location.search :"查询的字符串不存在";
14         str += "<br>锚点:"+location.hash;
15         document.write(str+"<hr>");
16 
17     </script>
18 </head>
19 <body>
20     <input type="button" value="刷新网页" onclick="location.reload()" />
21     
22     <a href="javascript:void(0)" onclick="history.go(-1)">进入上一页</a>
23 </body>
24 </html>

 

location对象

标签:地址   html   reload   tle   arch   ash   toc   put   新网   

原文地址:http://www.cnblogs.com/CAODADA/p/6160774.html

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