js 模拟jquery onready 事件
var ready = function(){
if(window.addEventListener){
window.addEventListener("DOMContentLoaded",handle,false);
}else{
try{
// IE
document.documentElement.doScroll('bottom');
handle();
}catch(e) {
setTimeout(arguments.callee, 1);
}
}
}
function handle(){
alert(document.getElementById("moveId"));
}
ready();
var obj = {
handle:function(){
alert("asdf");
}
}
addEvent(document.body,"click",obj.handle);
function addEvent(obj,eve,fn){
if(obj.addEventListener){
obj.addEventListener(eve,fn,false);
}else{
obj.attachEvent("on"+eve,function(){
fn.call(obj);
})
}
}