標籤:全域 version 瀏覽器 修改 nav mil 名稱 使用者 protoc
window
window全域範圍,而且表示瀏覽器視窗
window對象有innerWidth和innerHeight屬性,網頁淨寬高(調整視窗值會變)
相容性:IE<=8不支援
outerWidth和outerHeight屬性,可擷取瀏覽器視窗的整個寬高
navigator
navigator表示瀏覽器資訊
navigator.appName:瀏覽器名稱;
navigator.appVersion:瀏覽器版本;
navigator.language:瀏覽器設定語言;
navigator.platform:作業系統類型;
navigator.userAgent:瀏覽器設定的User-Agent字串;
資訊可以被使用者修改
var width = window.innerWidth || document.body.clientWidth;
screen
screen.width/height/colorDepth 返回螢幕寬/高/顏色位元
location
location對象表示當前頁面的URL資訊
可以通過location.href擷取。也可以獲得URL各個部分的值
location.protocol; // ‘http‘location.host; // ‘www.example.com‘location.port; // ‘8080‘location.pathname; // ‘/path/index.html‘location.search; // ‘?a=!&b=2‘location.hash; // ‘TOP‘
location.assign()載入一個新頁面。
location。reload()重新載入當前頁
if (confirm(‘重新載入當前頁‘ + location.href + ‘?‘)) { location.reload();} else { location.assign(‘/discuss‘); // 設定一個新的URL地址}document
document整個DOM的根節點
document.title = ‘努力學習JavaScript!‘;可以更改文檔標題
js_瀏覽器對象