document.currentScript

场景

 

如何得到正在执行的script元素

 

 

"新"货色:

 

 

document.currentScript;

 

来源

 

 

  • 非标准,适用在Gecko 2.0+(FF4+
  • 返回当前正在执行的<script>元素
 
应用
 
获取当前执行的script 是否异步执行
 
 
if(document.currentScript.async){
      //异步
}else{
     //同步
}

  

在线例子
 
----- 注意请用 ff4+查看!!!
 
https://developer.mozilla.org/samples/html/currentScript.html
 

 

 

 

扩展阅读:

 

https://github.com/seajs/seajs/issues/468

 

https://developer.mozilla.org/en-US/docs/DOM/document.currentScript

 

https://developer.mozilla.org/zh-CN/docs/DOM/document.currentScript

 

 

 

 

 

你可能感兴趣的:(currentScript)