load

load 事件發生在加載完目標資源、該資源依賴的其他資源時。

一般資訊

規範

DOM L3

介面

UIEvent

起泡事件

No

可取消

No

對象

Window

預設行為

None.

屬性

Property Type Description
target Read only EventTarget The event target (the topmost target in the DOM tree).
type Read only DOMString The type of event.
bubbles Read only Boolean Whether the event normally bubbles or not.
cancelable Read only Boolean Whether the event is cancellable or not.
view Read only WindowProxy document.defaultView (window of the document)
detail Read only long (float) 0.

範例

<script>
  window.addEventListener("load", function(event) {
    console.log("All resources finished loading!");
  });
</script>

規範

Specification
UI Events
# event-type-load
HTML Standard
# delay-the-load-event

相關事件