日期:2014-05-16  浏览次数:20393 次

【新手求解】'null' 为空或不是对象
<script type="text/javascript">
        window.onload = function () {
            var oBtn = document.getElementById("btn_change"); //获取btn点击的按钮
            oBtn.onclick = function () {
                //获取页面高度和宽度
                var sHeight = document.documentElement.scrollHeight;
                var sWidth = document.documentElement.scrollWidth;
                //alert(sHeight);
                //alert(sWidth);
                //可视区域的高度和宽度
                var wHeight = document.documentElement.clientHeight;
                //alert(wHeight)
                var oMask = document.createElement("div")//创建元素结点
                oMask.id = "div_mask";
                oMask.style.height = sHeight + "px";
                oMask.style.width = sWidth + "px";
                document.body.appendChild(oMask);
                var oLogin = document.createElement("div");
                oLogin.id = "div_login";
                oLogin.innerHTML = "<div class='logincon'><div id='div_close'></div></div>";
                document.body.appendChild(oLogin);
                //获取login的宽度和高度
                var dHeight = oLogin.offsetHeight;
                var dWidth = oLogin.offsetWidth;
                oLogin.style.left = (sWidth - dWidth) / 2 + "px";
                oLogin.style.top = (wHeight - dHeight) / 2 + "px";

                var oClose = document.getElementById("close");