js Window Document 中的 location 對象
window.location 與 document.location 的關系
window
和
document
中都有一個
location
屬性,都是
Location
對象
他們兩個的關系是:完全一模一樣,如下
===
Location 對象的一些屬性和方法
{
hash: ""
host: "localhost"
hostname: "localhost"
href: "http://localhost/diary/"
origin: "http://localhost"
pathname: "/diary/"
port: ""
search: ""
protocol: "http:"
reload: ƒ reload()
replace: ƒ ()
toString: ƒ toString()
}
常用使用方法
跳轉目前目錄下的頁面
location = 'add.html'
跳轉本站頁面
location.pathname = 'about.html'