天天看點

history、location、screen對象

1、history對象

window.history對象包含浏覽器的曆史(URL)集合

history.back()與在浏覽器點選後退按鈕相同

history.forward()與在浏覽器中點選按鈕向前相同

history.go()進入曆史中的某個頁面

2、location對象

window.location對象用于獲得目前頁面的位址,并把浏覽器重定向到新的頁面

location.hostname傳回web主機的域名

location.pathname傳回目前頁面的路徑和檔案名

location.port傳回web主機的端口

location.protocol傳回所使用的web協定

location.href傳回目前頁面的url

location.assign()加載新的文檔

3、screen對象

window.screen對象包含有關使用者螢幕的資訊

screen.availWidth可用螢幕寬度

screen.availHeight可用螢幕高度

screen.Height螢幕高度

screen.Width螢幕寬度

繼續閱讀