aboutsummaryrefslogtreecommitdiff
path: root/files/vi/web/events/load/index.html
blob: 130d6b9af0e0a4529982f13d5507f0e2ebce6b3e (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
title: load
slug: Web/Events/load
tags:
  - DOM
  - Event
  - Sự kiện
translation_of: Web/API/Window/load_event
---
<p>Sự kiện <strong><code>load</code></strong> có hiệu lực (được kích hoạt) khi các tài nguyên của một đối tượng hoặc các tài nguyên phụ thuộc vào đối tượng đó đã được tải nạp hoàn tất.</p>

<h2 id="Các_ví_dụ">Các ví dụ</h2>

<h3 class="brush: html" id="Window">Window</h3>

<pre class="brush: html">&lt;script&gt;
  window.addEventListener("load", function(event) {
    console.log("Tất cả các tài nguyên đã được tải nạp hoàn tất!");
  });
&lt;/script&gt;</pre>

<h3 class="brush: html" id="Phần_tử_script">Phần tử <code>script</code></h3>

<pre class="brush: html">&lt;script&gt;
  var script = document.createElement("script");
  script.addEventListener("load", function(event) {
    console.log("Script đã được tải nạp xong và thực thi");
  });
  script.src = "http://example.com/example.js";
  script.async = true;
  document.getElementsByTagName("script")[0].parentNode.appendChild(script);
&lt;/script&gt;</pre>

<h2 id="Thông_tin_cơ_bản">Thông tin cơ bản</h2>

<dl>
 <dt style="float: left; text-align: right; width: 120px;">Specification</dt>
 <dd style="margin: 0 0 0 120px;"><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/#event-type-load">DOM L3</a></dd>
 <dt style="float: left; text-align: right; width: 120px;">Giao diện</dt>
 <dd style="margin: 0 0 0 120px;">UIEvent</dd>
 <dt style="float: left; text-align: right; width: 120px;">Bubbles</dt>
 <dd style="margin: 0 0 0 120px;">Không</dd>
 <dt style="float: left; text-align: right; width: 120px;">Có thể hủy bỏ</dt>
 <dd style="margin: 0 0 0 120px;">Không thể</dd>
 <dt style="float: left; text-align: right; width: 120px;">Đối tượng</dt>
 <dd style="margin: 0 0 0 120px;">Window, Document, Element</dd>
 <dt style="float: left; text-align: right; width: 120px;">Hành động mặc địch</dt>
 <dd style="margin: 0 0 0 120px;">Không.</dd>
</dl>

<h2 id="Các_thuộc_tính">Các thuộc tính</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Thuộc tính</th>
   <th scope="col">Kiểu / Loại</th>
   <th scope="col">Mô tả</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code>target</code> {{readonlyInline}}</td>
   <td><code>{{domxref("EventTarget")}}</code></td>
   <td>Mục tiêu để áp dụng sự kiện (Đối tượng thuộc cây DOM).</td>
  </tr>
  <tr>
   <td><code>type</code> {{readonlyInline}}</td>
   <td><code>{{domxref("DOMString")}}</code></td>
   <td>Loại sự kiện</td>
  </tr>
  <tr>
   <td><code>bubbles</code> {{readonlyInline}}</td>
   <td><code>{{domxref("Boolean")}}</code></td>
   <td>Xác định sự kiện bình thường có bubbles hay không.</td>
  </tr>
  <tr>
   <td><code>cancelable</code> {{readonlyInline}}</td>
   <td><code>{{domxref("Boolean")}}</code></td>
   <td>Xác định sự kiện liệu có thể hủy bỏ được hay không.</td>
  </tr>
  <tr>
   <td><code>view</code> {{readonlyInline}}</td>
   <td><code>{{domxref("WindowProxy")}}</code></td>
   <td><code>{{domxref("Document.defaultView", "document.defaultView")}}</code> (<code>window</code> of the document)</td>
  </tr>
  <tr>
   <td><code>detail</code> {{readonlyInline}}</td>
   <td><code>long</code> (<code>float</code>)</td>
   <td>0.</td>
  </tr>
 </tbody>
</table>

<h2 id="Các_thông_số_kỹ_thuật">Các thông số kỹ thuật</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Thông số</th>
   <th scope="col">Trạng thái</th>
   <th scope="col">Diễn giải</th>
  </tr>
  <tr>
   <td>{{SpecName('UI Events', '#event-type-load', 'load')}}</td>
   <td>{{Spec2('UI Events')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'parsing.html#the-end:event-load', 'Load event')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Liên kết này đưa đến phần giải thích các bước được thực hiện khi quá trình tải nạp tài liệu kết thúc. Sự kiện 'load' cũng được kích hoạt ở nhiều phần tử. Và lưu ý rằng có nhiều chỗ trong Thông số kỹ thuật đề cập đến những thứ mà có thể "<a href="https://html.spec.whatwg.org/multipage/parsing.html#delay-the-load-event">Trì hoãn sự kiện load</a>".</td>
  </tr>
 </tbody>
</table>

<h2 id="Các_sự_kiện_liên_quan">Các sự kiện liên quan</h2>

<ul>
 <li>{{event("DOMContentLoaded")}}</li>
 <li>{{event("readystatechange")}}</li>
 <li>{{event("beforeunload")}}</li>
 <li>{{event("unload")}}</li>
</ul>