Element.onafterscriptexecute

  • Revision slug: DOM/element.onafterscriptexecute
  • Revision title: element.onafterscriptexecute
  • Revision id: 344549
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}{{gecko_minversion_header("2")}}

Summary

Fired when a static {{HTMLElement("script")}} element  finishes executing its script. Does not fire if the element is added dynamically, eg with appendChild().

Syntax

document.onafterscriptexecute = funcRef;

funcRef is a function reference, called when the event is fired. The event's target attribute is set to the script {{domxref("Element")}} that just finished executing.

Example

function finished(e) {
  logMessage("Finished script with ID: " + e.target.id);
}

document.addEventListener("afterscriptexecute", finished, true);

{{HTMLLiveSample("currentScript.html")}}

Specification

See also

  • {{domxref("element.onbeforescriptexecute")}}
  • {{domxref("document.currentScript")}}

Revision Source

<div>
  {{DomRef}}{{gecko_minversion_header("2")}}</div>
<h2 id="Summary">Summary</h2>
<p>Fired when a static {{HTMLElement("script")}}&nbsp;element &nbsp;finishes executing its script.&nbsp;Does not fire if the element is added dynamically, eg with appendChild().</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
<em>document.onafterscriptexecute = funcRef;</em>
</pre>
<p><em>funcRef</em> is a function reference, called when the event is fired. The event's <code>target</code> attribute is set to the script {{domxref("Element")}} that just finished executing.</p>
<h2 id="Example">Example</h2>
<pre class="brush:js">
function finished(e) {
  logMessage("Finished script with ID: " + e.target.id);
}

document.addEventListener("afterscriptexecute", finished, true);
</pre>
<p>{{HTMLLiveSample("currentScript.html")}}</p>

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

<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("element.onbeforescriptexecute")}}</li>
  <li>{{domxref("document.currentScript")}}</li>
</ul>
Revert to this revision