仿照DiscuzNT弹出框以及JS判断框架是否加载完毕,加载中...

普通页面判断加载完毕

<script type="text/javascript">
document.write('<div id="loadDiv" style="font-size: 14px;font-weight:bold; color:#0099cc;left: 50%;position: absolute;top:40%;"><img src="loading.gif"/> 加载中...</div>');
window.onload = function() {
document.getElementById("hiddenDiv").style.display="";   //显示页面内容  
document.getElementById("loadDiv").removeNode(true);   
}
</script>
<div id="hiddenDiv" style="display:none">
  <iframe src="http://www.qq.com/" width="100%" height="768px"></iframe>
</div>

----------以下是动态创建-------------

function sAlert(){
var msgw,msgh,bordercolor,tipClose;
    msgw    = 600;//提示窗口的宽度,高度
    msgh    = 400;
    bordercolor = "#73c4e0";//提示窗口的边框颜色,标题颜色
    tipClose    = "<div id='closeImg' style='width:20px;margin:12px auto 0 auto; text-align:right; padding-top:5px; padding-bottom:5px'><img id='qhImg' src='/images/close1.gif' class='hand' onmouseover=javascript:document.getElementById('qhImg').src='/images/close2.gif'; onmouseout=javascript:document.getElementById('qhImg').src='/images/close1.gif';></div>";

var sWidth,sHeight;
 sWidth = document.body.clientWidth;
 sHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;

//背景
var bgObj = document.createElement("div");
    bgObj.setAttribute('id', 'bgDiv');
    bgObj.style.position    = "absolute";
    bgObj.style.top         = "0";
    bgObj.style.background  = "#cccccc";
    bgObj.style.filter  = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
    bgObj.style.opacity = "0.6";
    bgObj.style.left    = "0";
    bgObj.style.width   = sWidth+"px";
    bgObj.style.height  = sHeight+"px";
    bgObj.style.zIndex  = "3000";
    //document.body.appendChild(bgObj);
//整个DIV
var msgObj = document.createElement("div");
    msgObj.setAttribute("id", "msgDiv");
    msgObj.setAttribute("align", "center");
    msgObj.style.background = "white ";
    msgObj.style.border     = "5px solid "+ bordercolor;
    msgObj.style.position   = "absolute";
    msgObj.style.left       = "44%";
    msgObj.style.top        = "27%";
    msgObj.style.marginLeft = "-225px"   ;
    msgObj.style.marginTop  = -75+document.documentElement.scrollTop+ "px";
    msgObj.style.width      = msgw + "px";
    msgObj.style.height     = msgh + "px";
    msgObj.style.textAlign  = "center";
    msgObj.style.lineHeight = "25px";
    msgObj.style.zIndex     = "10001";
//标题
var titleObj = document.createElement("h4");
    titleObj.setAttribute("id", "msgTitle");
    titleObj.setAttribute("align", "left");
    titleObj.style.margin      = "0";
    titleObj.style.padding     = "4px";
    //titleObj.style.background  = bordercolor;
    titleObj.style.filter  = "progid:DXImageTransform.Microsoft.Alpha(startX=20,startY=20,finishX=100,finishY=100,style=1,opacity=75,finishOpacity=100);";
    titleObj.style.opacity = "0.75";
    //titleObj.style.border  = "1px solid " + bordercolor;
    titleObj.style.height  = "40px";
    titleObj.style.fontSize= "18px";
    //titleObj.style.color   = "#000000";
    titleObj.innerHTML     = "<div id='loadDiv' style='font-size: 14px;margin-top:6px;font-weight:bold; color:#0099cc;'><img src='/images/common/loading.gif'/> 加载中...</div>";
//关闭窗口
var closeObj = document.createElement("div");
    closeObj.style.margin  = "0";
    closeObj.style.padding = "0";
    closeObj.style.width   = "580px";
    closeObj.style.height  = "20px";
    closeObj.style.color   = "white";
    closeObj.style.position= "absolute";
    closeObj.innerHTML     = tipClose;
    closeObj.style.cursor  = "pointer";
    closeObj.style.left    = "275px";
    closeObj.style.top     = "2px";
    document.body.appendChild(msgObj);
    document.getElementById("msgDiv").appendChild(titleObj);
    document.getElementById("msgDiv").appendChild(closeObj);
    closeObj.onclick = c;
    function c(){
    //document.body.removeChild(bgObj);
    document.body.removeChild(msgObj);
    }  
var iframeObj= document.createElement("div");
    iframeObj.setAttribute("id","hiddenDiv");
    iframeObj.innerHTML   ="<iframe id='regFrame' src='http://www.163.com' scrolling='no' frameborder='0' width='580' height='400' onload='emptyLoading();'></iframe>";
    document.getElementById("msgDiv").appendChild(iframeObj);
}
function emptyLoading(){parent.document.getElementById("msgTitle").innerHTML="";}

你可能感兴趣的:(discuz)