日期:2014-05-16  浏览次数:20486 次

加载JSON,IE下问题
IE下就是 不callback。。。
<script language='javascript'>
var _FBY={};
_FBY.getJSON=function(url,fun,charset){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.language = "javascript";
script.src=url;
if (!charset)
charset='utf-8';
script.charset = charset;
//为浏览器做兼容
script.onload = script.onreadystatechanged = function() {
if (!this.readyState || this.readyState == "loaded"
|| this.readyState == "complete") {
if (typeof (fun) == "function")
fun();
script.onload = script.onreadystatechanged = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
function callback(){
alert(123);
}

_FBY.getJSON('json.js',callback);
</script>

------解决方案--------------------
原来是这个没有后面那个d啊~·script.onreadystatechanged

呵呵``