?<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Strict//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml"?xml:lang="zh-CN">
<head>
<title>王者</title>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<style?type="text/css"?media="screen">
#mask{?background:#000;?opacity:0.6;?filter:alpha(opacity=6);?height:1000px;?width:100%;?position:absolute;?top:0;?left:0;?z-index:1000;}
#login{?position:fixed;?left:30%;?top:30%;?z-index:1001;}
.loginCon{
width:400px;?height:380px;?background:#f0f;?position:relative;
}
#close{?width:30px;?height:30px;?background:#fff;?cursor:pointer;?position:absolute;?right:5px;top:5px;}
?</style>
<script?type="text/javascript">
?window.onload=function(){
??var?oBtn=document.getElementById("btnLogin");?
??//獲取瀏覽器的高度和寬度
???var?sHeight=document.documentElement.scrollHeight;
???var?sWidth=document.documentElement.scrollWidth;
????
???//可視區域的高度和寬度
???var?wHeight=document.documentElement.clientHeight;
??
?
??var?oMask=document.createElement("div");//創建節點DIV,給div一個ID,mask
??????oMask.id="mask";
??oMask.style.height=sHeight+"px";
??oMask.stylewidth=sWidth+"px";
??document.body.appendChild(oMask);//在頁面尾部追加節點
??
??var?oLogin=document.createElement("div");
??????oLogin.id="Login";
??oLogin.innerHTML="<div?class='loginCon'><div?id='close'?style='text-align:center;'>x</div></div>";//把傳入的DIV插入到節點中
??document.body.appendChild(oLogin);?
??????//獲取Login的寬度和高度
??var?dHeight=oLogin.offsetHeight;
??var?dWidth=oLogin.offsetHeight;
??
??oLogin.style.left=(sWidth-dWidth)/2+"px";
??oLogin.style.top=(wHeight-dHeight)/2+"px";
?}
</script>?
</head>
<body>
???<!--<div?id="mask"></div>
???<div?id="login">
?????<div?class="loginCon">
???????<div?id="close"?style="text-align:center;">x</div>
?????</div>
???</div>-->
</body>
</html>
2015-08-23
<style?type="text/css"?media="screen">格式好像寫錯了吧