penven

博客园 首页 新随笔 联系 订阅 管理

css 加载完毕后加载页面,避免用户的不良视觉效果

var _PageHeight = document.documentElement.clientHeight,
    _PageWidth = document.documentElement.clientWidth;

var _LoadingTop = _PageHeight > 61 ? (_PageHeight - 61) / 2 : 0,
    _LoadingLeft = _PageWidth > 215 ? (_PageWidth - 215) / 2 : 0;

var Loadimagerul = "/Content/LoadJs/Image/loading.gif";

var _LoadingHtml = '<div id="loadingDiv" style="position:absolute;font-size: 32px;left:0;width:100%;height:' + _PageHeight + 'px;top:0;background:#f3f8ff;opacity:1;filter:alpha(opacity=80);z-index:10000;"><div style="position: absolute; cursor1: wait; left: ' + _LoadingLeft + 'px; top:' + _LoadingTop + 'px; width:200px;; height: 57px; line-height: 57px; padding-left: 50px; padding-right: 5px; color: #999; font-family:\'Microsoft YaHei\';">玩命加载中...</div></div>';

document.write(_LoadingHtml);

document.onreadystatechange = completeLoading;

function completeLoading() {
    if (document.readyState == "complete") {
        var loadingMask = document.getElementById('loadingDiv');
        loadingMask.parentNode.removeChild(loadingMask);
    }
}

 

posted on 2017-01-06 17:21  penven  阅读(149)  评论(0编辑  收藏  举报