同一个调整div尺寸的方法,执行两次,结果不一样
<html> <head> </head> <script> function showDiv() { var obj = document.getElementById("myDiv"); obj.style.display = ''; obj.style.width = "100%"; obj.style.height = "100%"; var height = obj.style.pixelHeight; var width = obj.style.pixelWidth; alert(height + "," + width); } </script> <body onload ="showDiv()"> <input type="button" onclick="showDiv()" value="显示DIV" style="position:absolute;left:5px;top:5px; z-index:2;" /> <div id="myDiv" style="position: absolute; display:none;background-color:silver;left:0px;top:0px">123 </div> </body> </html>