這篇文章主要介紹了浏覽器窗口加載和大小改變事件,需要的朋友可以參考下
代碼如下: window.onload = function() { var height = document.body.clientHeight; document.getElementById("vivS").style.height = (height - 20) + "px"; document.getElementById("emd").style.height = (height - 20) + "px"; document.getElementById("ob").style.height = (height - 20) + "px"; }; window.onresize = function() { height = document.body.clientHeight; document.getElementById("vivS").style.height = (height - 20) + "px"; document.getElementById("emd").style.height = (height - 20) + "px"; document.getElementById("ob").style.height = (height - 20) + "px"; };