<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
</head>
<body>
<script type="text/javascript">
(function(root){
    function ready(callback){
        if(document.addEventListener){
            document.addEventListener("DOMContentLoaded",callback,false);
        }else{
            (function(){
                try{
                    document.documentElement.doScroll("top");
                    callback();
                }catch(e){
                    setTimeout(arguments.callee,5);
                    return;
                }
            })()
        }
    }
    root.ready=ready;
})(window);
</script>

<script type="text/javascript">
window.ready(function(){
    var div=document.getElementById("div");
    alert(div.innerHTML);
});
</script>

<div id="div">111</div>

</body>
</html>

非IE浏览器使用DomContentLoaded,IE浏览器使用document.documentElement.doScroll("left")---IE的DOM一旦准备完毕就可以使用这个方法来判定。

注意iframe还是使用IE下ifr.attachEvent("onload",callback),其他浏览器使用onload=function。