Location網址列物件
#href:取得網址列中完整的位址。可以實現JS的網頁跳轉。 location.href = “http://www.sina.com.cn”;
#hostname:主機名稱
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //实例:测试不同浏览器 var str = "<h2>地址栏对象</h2>"; str += "地址栏地址:"+location.href; str += "<br>主机名:"+location.hostname; str += "<br>文件路径及文件名:"+location.pathname; str += "<br>协议:"+location.protocol; document.write(str+"<hr>"); </script> </head> <body > </body> </html>
#下一節