问题描述
这里是js代码window.onload=function(){varoBtn=document.getElementById("btnLogin");oBtn.onclick=function(){//获取页面的高度和宽度varsHeight=document.documentElement.scrollHeight;varsWidth=document.documentElement.scrollWidth;//可视化区域的高度和宽度varwHeight=document.documentElement.clientHeight;varoMask=document.createElement("div");oMask.id="mask";oMask.style.height=sHeight+"px";oMask.style.width=sWidth+"px";document.body.appendChild(oMask);varoLogin=document.createElement("div");oLogin.id="login";oLogin.innerHTML="<divclass='loginCon'><h1align='center'class='Welcome'>欢迎</h1><palign='center'class='textLogin'>登录你的账户</p><spanID='lblAccount'>账号:</span><inputname='txtAccount'id='txtAccount'type='text'placeholder='账号'><spanID='lblPassword'>密码:</span><inputname='txtPassWord'id='txtPassWord'type='text'placeholder='密码'><inputname='btnSubmit'class='btnSubmit'id='btnSubmit'type='submit'value='登录'><divid='close'>X</div></div>"document.body.appendChild(oLogin);//获取login的高度和宽度vardHeight=oLogin.offsetHeight;vardWidth=oLogin.offsetWidth;//给login的left和top赋值oLogin.style.left=(sWidth-dWidth)/2+"(px)";oLogin.style.top=(sHeight-dHeight)/2+"(px)";varoClose=document.getElementById("close");oMask.onclick=oClose.onclick=function(){document.body.removeChild(oMask);document.body.removeChild(oLogin);}}}重点是这个oLogin.innerHTML="<divclass='loginCon'><h1align='center'class='Welcome'>欢迎</h1><palign='center'class='textLogin'>登录你的账户</p><spanID='lblAccount'>账号:</span><inputname='txtAccount'id='txtAccount'type='text'placeholder='账号'><spanID='lblPassword'>密码:</span><inputname='txtPassWord'id='txtPassWord'type='text'placeholder='密码'><inputname='btnSubmit'class='btnSubmit'id='btnSubmit'type='submit'value='登录'><divid='close'>X</div></div>"