Created
October 9, 2014 01:43
-
-
Save alanerzhao/7a6a73777f1cd97b342e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//load cnzz | |
function loadScript(id,src, callback) { | |
var cnzz_protocol = (("https:" == document.location.protocol) ? " https://": " http://"); | |
var cnzz_url = ""+cnzz_protocol+"w.cnzz.com/q_stat.php?id=" + id + ""; | |
var s, r, t; | |
r = false; | |
s = document.createElement('script'); | |
s.defer = "defer"; | |
s.async="async"; | |
s.type = 'text/javascript'; | |
s.src = src || cnzz_url; | |
s.onload = s.onreadystatechange = function() { | |
if (!r && (!this.readyState || this.readyState == 'complete')) { | |
r = true; | |
callback && callback(); | |
} | |
}; | |
t = document.getElementsByTagName('script')[0]; | |
t.parentNode.insertBefore(s, t); | |
} | |
//封装多事件 | |
function bindEvent(obj, ev, fn) { | |
if (obj.addEventListener) { | |
obj.addEventListener(ev, fn, false); | |
} else if(obj.attachEvent) { | |
obj.attachEvent('on' + ev, function() { | |
fn.call(obj); | |
}) | |
} else { | |
obj['on'+ ev] = fn; | |
} | |
} | |
bindEvent(window,"load",function(){ | |
loadScript("1000008655"); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment