load

load 이벤트는 리소스와 그것에 의존하는 리소스들의 로딩이 완료되면 실행됩니다.

예제

Window

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

script 엘리먼트

html
<script>
  var script = document.createElement("script");
  script.addEventListener("load", function (event) {
    console.log("Script finished loading and executing");
  });
  script.src = "http://example.com/example.js";
  script.async = true;
  document.getElementsByTagName("script")[0].parentNode.appendChild(script);
</script>

일반 정보

스펙

DOM L3

인터페이스

UIEvent

Bubbles

No

취소가능 여부

No

타겟

Window,Document,Element

기본 동작

None.

속성

속성 타입 설명
target 읽기 전용 EventTarget The event target (the topmost target in the DOM tree).
type 읽기 전용 DOMString The type of event.
bubbles 읽기 전용 Boolean Whether the event normally bubbles or not.
cancelable 읽기 전용 Boolean Whether the event is cancellable or not.
view 읽기 전용 WindowProxy document.defaultView (window of the document)
detail 읽기 전용 long (float) 0.

명세서

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

관련 이벤트