function loadScript(url, callback, charset){
charset = charset || 'utf-8';
callback = callback ||
function(){
};
var t = document.createElement("script");
t.type = "text/javascript";
t.charset = charset;
t.src = url;
var _fun = function(){
if (t.onreadystatechange) {
t.onreadystatechange = null;
}
else {
t.onload = null;
}
_fun = null; // 此句感觉无效
document.getElementsByTagName("head")[0].removeChild(t);
callback();
};
if (typeof t.onreadystatechange != "undefined") {
t.onreadystatechange = function(){
if (t.readyState == 'complete' || t.readyState == 'loaded') {
_fun();
}
};
}
else {
t.onload = _fun;
}
//此句可能有bug
//document.getElementsByTagName("head")[0].appendChild(t);
document.getElementsByTagName("head")[0].insertBefore(t,document.getElementsByTagName("head")[0].firstChild);
}
function addEventListener(dom, eventName, fn){
if (dom.addEventListener) {
dom.addEventListener(eventName, fn, false);
}
else if (dom.attachEvent) {
dom.attachEvent("on" + eventName, fn);
}
else
{
dom["on" + eventName] = fn;
}
}