KindEditor 4.1.2 ie6 loadScript bug

KindEditor 

版本4.1.2

ie6 下_loadScript方法 bug

源码如下:

function _loadScript(url, fn) {
	var head = document.getElementsByTagName('head')[0] || (_QUIRKS ? document.body : document.documentElement),
		script = document.createElement('script');
	head.appendChild(script);
	script.src = url;
	script.charset = 'utf-8';
	script.onload = script.onreadystatechange = function() {
		if (!this.readyState || this.readyState === 'loaded') {
			if (fn) {
				fn();
			}
			script.onload = script.onreadystatechange = null;
			head.removeChild(script);
		}
	};
}

将该段代码更改为如下代码即可正常运行:

function _loadScript(url, fn) {
	var head = document.getElementsByTagName('head')[0] || (_QUIRKS ? document.body : document.documentElement),
		script = document.createElement('script');
	script.src = url;
	script.charset = 'utf-8';
    var done = false;
	script.onload = script.onreadystatechange = function() {
	    if (!done && (!this.readyState ||
	            this.readyState === "loaded" || this.readyState === "complete")) {
	        done = true;
	        if (fn) {
	        	fn();
	        }
	        script.onload = script.onreadystatechange = null;
	        if (head && script.parentNode) {
	            head.removeChild(script);
	        }
	    }
	};
	head.insertBefore(script, head.firstChild);
}


你可能感兴趣的:(function,IE,null,url)