日期:2014-05-16  浏览次数:20608 次

如何让这样的div代码适合标准页面?? - Web 开发 / Ajax
我在网站的登录页面建了一个这样的div错误层,当用户登录出错误时,就弹出一个对话框,同时网页被灰色背景遮住。
<div id="Layer1" style="position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:1; background-image: url(images/div_bg.jpg); border: 1px none #000000;" class="img">密码错误!</div>

现在错误的效果是:如果在网页的头部加上
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
代码就不能出现div层遮住整个页面的效果,IE下失败,在firefox下有效果。去掉上面这段代码的话IE和firefox都可以,应该怎样改一下,使其都适应呢?

------解决方案--------------------
<script>

window.onload=function(){
 document.getElementById("Layer1").style.height=screen.height;
}
</script>