﻿//div代码
document.write("<div id='divModal'></div>");
document.write("<dIV id='divModalDialog'>");
document.write("<div class='titleBar'>");
document.write("<div class='titleName' id='mytitle'></div>");
document.write("<div class='closeButton' title='关闭'><a href='javascript:closeModel();' style='color:#fff;'>×</a></div>");
document.write("</div>");
document.write("<div class='mainBody'>");
document.write("<iframe id='myframe' src='about:blank' marginheight=0 marginwidth=0 width='100%' height='100%' frameborder=0></iframe>");
document.write("</div>");
document.write("</DIV>");

//css代码
document.write("<style>");
document.write("div.titleBar{background:#666; color:#fff; margin:0px auto; width:100%; padding:5px; line-height:16px; border-bottom:#666 solid 1px;}");
document.write("div.titleName{float:left; font-weight:bold;}");
document.write("div.closeButton{float:right; font-weight:bold;}");
document.write("div.mainBody{margin:auto;}");
document.write("#divModalDialog{border:solid 1px #666; background:#DBDBDB; POSITION:absolute; left:0px; top:0px; DISPLAY:none; z-index:49;}");
document.write("#divModal{BACKGROUND-COLOR:white; FILTER:alpha(opacity=75); LEFT:0px; POSITION:absolute; TOP:0px;}");
document.write("</style>");

//js代码 
function showModel(w,h,url,title)//*html页面直接调此函数 w-宽度，h-高度，url-链接，title-窗口标题*/
{
    divModalDialog.style.display = "block";
    divModalDialog.style.width=w;
    divModalDialog.style.height=h;
    document.all["myframe"].src=url;
    mytitle.innerHTML=title;
    resizeModal();
    window.onresize = resizeModal;
}

function closeModel()//执行关闭弹出窗口
{
    divModal.style.width = "0px";
    divModal.style.height = "0px";
    divModalDialog.style.display = "none";
    window.onresize = null;
}

function resizeModal()//执行要屏蔽的窗口
{
    divModal.style.width = document.documentElement.scrollWidth;
    divModal.style.height = document.documentElement.scrollHeight;
    //divModalDialog.style.left = ((document.documentElement.clientWidth - divModalDialog.offsetWidth) / 2);
	divModalDialog.style.left = ((document.documentElement.clientWidth - divModalDialog.offsetWidth) / 2);
    //divModalDialog.style.top = (document.documentElement.scrollTop+(document.documentElement.clientHeight - divModalDialog.offsetHeight) / 2);
	divModalDialog.style.top = (document.documentElement.scrollTop+(document.documentElement.clientHeight - divModalDialog.offsetHeight) / 2);
    //divModalDialog.style.top = ((document.body.offsetHeight - divModalDialog.offsetHeight) / 2);
        
}
//--------div+css end-----------//

