Skip to content

Instantly share code, notes, and snippets.

@xhinking
Created June 2, 2012 12:01
Show Gist options
  • Save xhinking/2858045 to your computer and use it in GitHub Desktop.
Save xhinking/2858045 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
function addEventSimple(obj,evt,fn){
if(obj.addEventListener){
obj.addEventListener(evt,fn,false);
}else if(obj.attachEvent){
obj.attachEvent('on'+evt,fn);
}
}
addEventSimple(window,'load',init);
function init(){
addEventSimple(document,'click',clickFunc);
}
function clickFunc(e){
// do some thing here..
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment