aboutsummaryrefslogtreecommitdiff
path: root/files/ar/web/api/window/domcontentloaded_event/index.html
blob: d585930f1fbb601a501da8b28fa3a093d219b783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: 'Window: DOMContentLoaded event'
slug: Web/API/Window/DOMContentLoaded_event
translation_of: Web/API/Window/DOMContentLoaded_event
---
<div>{{APIRef}}</div>

<p dir="rtl">يبدأ حدث DOMContentLoaded عند تحميل مستند HTML الأولي وتحليله بالكامل ، دون انتظار انتهاء تحميل صفحات الأنماط والصور والأطر الفرعية.</p>

<table class="properties">
 <tbody>
  <tr>
   <th dir="rtl" scope="row">Bubbles</th>
   <td dir="rtl">Yes</td>
  </tr>
  <tr>
   <th scope="row">Cancelable</th>
   <td>Yes (although specified as a simple event that isn't cancelable)</td>
  </tr>
  <tr>
   <th scope="row">Interface</th>
   <td>{{domxref("Event")}}</td>
  </tr>
  <tr>
   <th scope="row">Event handler property</th>
   <td>None</td>
  </tr>
 </tbody>
</table>

<p>The original target for this event is the {{domxref("Document")}} that has loaded. You can listen for this event on the <code>Window</code> 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.</p>

<p>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 <code>load</code> where <code>DOMContentLoaded</code> would be more appropriate.</p>

<h2 id="Examples">Examples</h2>

<h3 id="Basic_usage">Basic usage</h3>

<pre class="brush: js notranslate">window.addEventListener('DOMContentLoaded', (event) =&gt; {
    console.log('DOM fully loaded and parsed');
});
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'indices.html#event-domcontentloaded')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.Window.DOMContentLoaded_event")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>Related events: {{domxref("Window/load_event", "load")}}, {{domxref("Document/readystatechange_event", "readystatechange")}}, {{domxref("Window/beforeunload_event", "beforeunload")}}, {{domxref("Window/unload_event", "unload")}}</li>
 <li>This event on {{domxref("Document")}} targets: {{domxref("Document/DOMContentLoaded_event", "DOMContentLoaded")}}</li>
</ul>