Element.onbeforescriptexecute

  • Revision slug: Web/API/element.onbeforescriptexecute
  • Revision title: element.onbeforescriptexecute
  • Revision id: 405489
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Markup.Moved From DOM/element.onbeforescriptexecute to Web/API/element.onbeforescriptexecute

Revision Content

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

Summary

Fired when the code in a {{HTMLElement("script")}} element declared in an HTML document is about to start executing. Does not fire if the element is added dynamically, eg with appendChild().

Syntax

document.onbeforescriptexecute = 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 is about to be executed.

Example

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

document.addEventListener("beforescriptexecute", starting, true);

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

Specification

See also

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

Revision Source

<div>{{DomRef}}{{gecko_minversion_header("2")}}</div>

<h2>Summary</h2>

<p>Fired when the code in a {{HTMLElement("script")}}&nbsp;element declared in an HTML document&nbsp;is about to start executing. Does not fire if the element is added dynamically, eg with appendChild().</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
<em>document.onbeforescriptexecute = 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 is about to be executed.</p>

<h2 id="Example">Example</h2>

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

document.addEventListener("beforescriptexecute", starting, 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.onafterscriptexecute")}}</li>
  <li>{{domxref("document.currentScript")}}</li>
</ul>
Revert to this revision