aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/afterscriptexecute_event/index.html
blob: ea939df105c943452b4af8684a7c9e58cb1acf1f (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
---
title: element.onafterscriptexecute
slug: Web/API/Document/afterscriptexecute_event
tags:
  - DOM
  - onafterscriptexecute
translation_of: Web/API/Document/onafterscriptexecute
original_slug: Web/API/Document/onafterscriptexecute
---
<div>{{ApiRef}}{{gecko_minversion_header("2")}}</div>

<h2 id="概述">概述</h2>

<p>当HTML文档中的{{HTMLElement("script")}}标签内的代码执行完毕时触发该事件,如果这个<code>script</code>标签是用<code>appendChild()</code>等方法动态添加上去的,则不会触发该事件.</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><em>document.onafterscriptexecute = funcRef;</em>
</pre>

<p><code>afterscriptexecute</code>事件触发时,<code>funcRef</code>函数就会被调用. 传入参数<code>event</code><code>target</code>属性指向触发该事件的那个<code>script</code>元素.</p>

<h2 id="例子">例子</h2>

<pre class="brush:js">function finished(e) {
  logMessage("Finished script with ID: " + e.target.id);
}

document.addEventListener("afterscriptexecute", finished, true);
</pre>

<p><a href="/samples/html/currentScript.html">查看在线演示</a></p>

<h2 id="规范">规范</h2>

<ul>
 <li><a href="http://www.whatwg.org/specs/web-apps/current-work/#the-script-element">HTML5</a></li>
</ul>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{domxref("element.onbeforescriptexecute")}}</li>
 <li>{{domxref("document.currentScript")}}</li>
</ul>