Document: afterscriptexecute event
{{APIRef("DOM")}}{{non-standard_header}}
The afterscriptexecute event fires when a static {{HTMLElement("script")}} element finishes executing its script. It does not fire if the element is added dynamically, such as with {{domxref("Node.appendChild()", "appendChild()")}}.
Syntax
Use the event name in {{domxref("EventTarget/addEventListener", "addEventListener()")}}:
addEventListener("afterscriptexecute", (event) => { })
Alternatively, assign to the event handler property of the interface:
onafterscriptexecute = (event) => { }
Event type
A generic {{domxref("Event")}}.
Examples
function finished(e) {
logMessage(`Finished script with ID: ${e.target.id}`);
}
document.addEventListener("afterscriptexecute", finished);
// Or (but note that this replaces other event listeners
// added using onafterscriptexecute, if any)
document.onafterscriptexecute = finished;
Specifications
Not part of any specification.
Browser compatibility
{{Compat}}
See also
- {{domxref("Document.beforescriptexecute_event", "beforescriptexecute")}} event of
Document - {{domxref("Document.currentScript")}}
这篇文档对你有帮助吗?
谢谢你的反馈!