afterscriptexecute事件

Fellow Mozillian Daniel Buchner, curator of the X-Tag project and clever developer who showed us how to detect dom node insertions using CSS animations, recently showed me a new JavaScript feature I'd never heard of:  the SCRIPT element's afterscriptexecute event.  This event, when detected within the document, provides developers insight as to when specific SCRIPT elements are executed.

研究员Mozillian 丹尼尔·毕希纳的馆长X-标签项目和聪明的开发商谁向我们展示了如何检测使用CSS动画的DOM节点插入 ,最近发现我一个新JavaScript功能,我从来没有听说过的:在SCRIPT元素的afterscriptexecute事件。 在文档中检测到此事件后,开发人员可以洞悉何时执行特定的SCRIPT元素。

The following snippet listens for script executions on the page and logs the specific SCRIPT element to the console after executed:

以下代码段侦听页面上的脚本执行,并在执行后将特定的SCRIPT元素记录到控制台:


<script id="my_script" type="text/javascript">
document.addEventListener('afterscriptexecute', function(e){
  console.log('Script executed: ', e.target);
}, false);
</script>

<script type="text/javascript">console.log('foo')</script>

<script type="text/javascript">console.log('bar')</script>



This technique will be incredibly useful for debugging complex JavaScript applications, allowing developers to know exactly which script had just been injected and executed.

该技术对于调试复杂JavaScript应用程序非常有用,它使开发人员可以准确地知道刚刚注入并执行了哪个脚本。

Daniel has a knack for finding useful new techniques and this tip will be helpful down the road.  Unfortunately only Firefox has implemented this event but I look forward to WebKit support soonish.  Can you think of how you'd use this event?

丹尼尔(Daniel)有找到有用的新技术的诀窍,这个技巧对以后的工作很有帮助。 不幸的是,只有Firefox实施了此活动,但我希望WebKit尽快得到支持。 您能想到如何使用此事件吗?

翻译自: https://davidwalsh.name/afterscriptexecute

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值