element.onbeforescriptexecute

概述

当 HTML 文档中的<script>标签内的代码将要执行时触发该事件,如果这个script标签是用appendChild()等方法动态添加上去的,则不会触发该事件。

语法

document.onbeforescriptexecute = funcRef;

beforescriptexecute事件触发时,funcRef函数就会被调用。传入参数eventtarget属性指向触发该事件的那个script元素。

例子

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

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

查看在线演示

规范

参见