这里为什么 无法获取 宽 高
www.style.width=document.body.offsetWidth;
www.style.height=document.body.offsetHeight;
断点以上两行
document.body.offsetWidth
document.body.offsetHeight
都有确定的值
但就是没法赋给width 和 height
<style>
#www{
background-color:#0F0;
}
</style>
<script>
function fun(){
var www=document.getElementById('www');
www.style.width=document.body.offsetWidth;
www.style.height=document.body.offsetHeight;
www.style.opacity=0.5;
}
</script>
</head>
<body>
<div id="www" onclick="fun()">
哇哈哈
</div>
function fun()
{
var www = document.getElementById('www');
www.style.width = document.body.offsetWidth+'px';
www.style.height = document.body.offsetHeight+'px';
www.style.opacity = 0.5;
}