location網(wǎng)址列對象
Location網(wǎng)址列物件
#href:取得網(wǎng)址列中完整的位址??梢詫崿F(xiàn)JS的網(wǎng)頁跳轉(zhuǎn)。 location.href = “http://www.sina.com.cn”;
#hostname:主機名稱
- ##pathname:檔案路徑及檔名
- search:查詢字串。
- protocol:協(xié)議,如:http://、ftp://
- #hash:錨點名稱。如:#top
- reload([true]):重新整理網(wǎng)頁。 true參數(shù)表示強制刷新
<!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>協(xié)議:"+location.protocol; document.write(str+"<hr>"); </script> </head> <body > </body> </html>
#