From 6acf87987baea4675dbd1d5586663959e742cc03 Mon Sep 17 00:00:00 2001 From: MDN Date: Tue, 22 Feb 2022 00:12:14 +0000 Subject: [CRON] sync translated content --- .../document/beforescriptexecute_event/index.html | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 files/zh-cn/web/api/document/beforescriptexecute_event/index.html (limited to 'files/zh-cn/web/api/document/beforescriptexecute_event/index.html') diff --git a/files/zh-cn/web/api/document/beforescriptexecute_event/index.html b/files/zh-cn/web/api/document/beforescriptexecute_event/index.html new file mode 100644 index 0000000000..1835407a01 --- /dev/null +++ b/files/zh-cn/web/api/document/beforescriptexecute_event/index.html @@ -0,0 +1,45 @@ +--- +title: element.onbeforescriptexecute +slug: Web/API/Document/beforescriptexecute_event +tags: + - DOM + - onbeforescriptexecute +translation_of: Web/API/Document/onbeforescriptexecute +original_slug: Web/API/Document/onbeforescriptexecute +--- +
{{ApiRef}}{{gecko_minversion_header("2")}}
+ +

概述

+ +

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

+ +

语法

+ +
document.onbeforescriptexecute = funcRef;
+
+ +

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

+ +

例子

+ +
function starting(e) {
+  logMessage("Starting script with ID: " + e.target.id);
+}
+
+document.addEventListener("beforescriptexecute", starting, true);
+
+ +

查看在线演示

+ +

规范

+ + + +

相关链接

+ + -- cgit v1.2.3-54-g00ecf