码迷,mamicode.com
首页 > Web开发 > 详细

如何判断js是否加载完全

时间:2015-04-07 17:20:15      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

var script=document.createElement(‘script‘);
  		if(script.onreadystatechange){
  			script.onreadystatechange=function(){
  			if(this.readyState===‘loaded‘ || this.readyState===‘complete‘){
  				script.onreadystatechange=null;
  				callback();
  			}
  			}
  		}else{
  			script.onload=function(){
  				callback();
  			}
  		}
  		script.setAttribute("src",url);
  		document.body.appendChild(script);

  

如何判断js是否加载完全

标签:

原文地址:http://www.cnblogs.com/dunken/p/4398747.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!