首页 > 其他 > 详细

location对象

时间:2016-12-11 22:49:53      阅读:231      评论:0      收藏:0      [点我收藏+]
 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对象

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!