1. 程式人生 > >location對象

location對象

port ash 從服務器 查詢 demo .html div nbsp cat

對location進行梳理,平時用的時候都是用什麽看什麽,今天把location整理一下,方便查詢

完整的URL地址:http://192.168.5.203:8888/demo/demo.html?name=fly&age=18#怪誕咖啡
location  =>  http://192.168.5.203:8888/demo/demo.html?name=fly&age=18#怪誕咖啡
hash      =>  #怪誕咖啡
host      =>  192.168.5.203:8888
hostname  =>  192.168.5.203
href      =>  http://192.168.5.203:8888/demo/demo.html?name=fly&age=18#怪誕咖啡
origin    =>  http://192.168.5.203:8888
pathname  =>  /demo/demo.html
port      =>  8888
protocol  =>  http:
search    =>  ?name=fly&age=18

location.assign(‘地址‘) 等同於 location.href = ‘地址‘ 和 window.location = ‘地址‘

後兩者使用的時候,也是觸發assign()方法,進行跳轉的

跳轉到新的頁面,又可以把歷史記錄中的地址替換掉

location.replace(‘地址‘)

重新加載當前頁面:

location.reload() 有可能從緩存中加載

location.reload(true) 從服務器重新加載

location對象