javascript: The Browser Object Model(BOM)

來源:互聯網
上載者:User
window
  • window對象是瀏覽器或者架構自身.top總是瀏覽器,parent是父架構,self表示自己.
    window通常可以省略.
  • 視窗操作: moveBy(dx, dy), moveTo(x, y),
    resizeBy(dw, dh), resizeTo(w, h).
  • 導航: window.open(url, frame
    name, attribute). attribute可以是left, top, height, width, resizable,
    scrollable, toolbar, status, location(all default no). 

    • window.open
      返回新視窗引用,並且有一個opener對象表示父視窗
    • window.close.
  • 對話方塊:
    alert, confirm, prompt.
  • 狀態列: window.status, window.defaultStatus

  • 間間隔和暫停: timeoutId = setTimeout("alert('hello world')", 1000);
    clearTimeout(timeoutId);類似有setInterval和clearInterval.
  • 曆史:
    window.history.go(+-n), history.back, history.forward. history.length

document
  • alert(window.document
    == document) == true. 他是唯一一個既屬於DOM又屬於BOM的對象
  • 屬性:title, URL,
    referrer, lastModified
  • 集合屬性: anchors, applets, embeds, forms,
    images, links.
  • 方法: write, writeln.
    必須在完全載入頁面前調用write()和writeln()方法. 如果任何一個方法是在頁面載入後調用的,它將抹去頁面的內容,顯示指定的內容.

location
  • window和
    document的屬性,相互等價.
  • 屬性: hash(位於#後面的東西), host, hostname, href,
    pathname, port, protocol, search(位於?後面的東西).
  • 方法: assign(),
    replace(), reload(false=從緩衝中匯入(default),true=從伺服器端匯入)

navigator和
screen對象
  • navigator對象表示了瀏覽器本身,可以擷取一些屬性,但是各個瀏覽器支援不同.
  • screen
    對象可以得到使用者系統的資訊,如availHeight, availWidth(可用螢幕寬度和高度,排除了系統工作列), colorDepth,
    height, width.
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.