Element.onbeforescriptexecute

  • Revision slug: DOM/element.onbeforescriptexecute
  • Revision title: element.onbeforescriptexecute
  • Revision id: 44151
  • Created:
  • Creator: Johnjbarton
  • Is current revision? No
  • Comment 19 words added, 1 words removed

Revision Content

{{ DomRef() }}{{ non-standard_header() }}

{{ gecko_minversion_header("2") }}

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") }}

See Also

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

Specification

Not part of any specification.

Revision Source

<p>{{ DomRef() }}{{ non-standard_header() }}</p>
<p>{{ gecko_minversion_header("2") }}</p>
<p>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().</p>
<h3 class="editable"><span>Syntax </span></h3>
<pre class="eval"><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>
<h3 class="editable"><span>Example</span></h3>
<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>
<h3 class="editable">See Also</h3>
<ul> <li>{{ domxref("element.onafterscriptexecute") }}</li> <li>{{ domxref("document.currentScript") }}</li>
</ul>
<h3 class="editable"><span>Specification </span></h3>
<p>Not part of any specification.</p>
Revert to this revision