--- title: 'Window: DOMContentLoaded event' slug: Web/API/Window/DOMContentLoaded_event translation_of: Web/API/Window/DOMContentLoaded_event ---
يبدأ حدث DOMContentLoaded عند تحميل مستند HTML الأولي وتحليله بالكامل ، دون انتظار انتهاء تحميل صفحات الأنماط والصور والأطر الفرعية.
Bubbles | Yes |
---|---|
Cancelable | Yes (although specified as a simple event that isn't cancelable) |
Interface | {{domxref("Event")}} |
Event handler property | None |
The original target for this event is the {{domxref("Document")}} that has loaded. You can listen for this event on the Window
interface to handle it in the capture or bubbling phases. For full details on this event please see the page on the Document: {{domxref("Document/DOMContentLoaded_event", "DOMContentLoaded")}} event.
A different event, {{domxref("Window/load_event", "load")}}, should be used only to detect a fully-loaded page. It is a common mistake to use load
where DOMContentLoaded
would be more appropriate.
window.addEventListener('DOMContentLoaded', (event) => { console.log('DOM fully loaded and parsed'); });
Specification | Status |
---|---|
{{SpecName('HTML WHATWG', 'indices.html#event-domcontentloaded')}} | {{Spec2('HTML WHATWG')}} |
{{Compat("api.Window.DOMContentLoaded_event")}}