js_瀏覽器對象

來源:互聯網
上載者:User

標籤:全域   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_瀏覽器對象

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.