调整窗口大小时更新窗口内部高度(Update window innerheight when resizing window)
到目前为止,我已经成功地使Id具有与窗口相同的innerHeight。 但是,当我调整窗口大小时,高度保持不变。
任何人都可以帮助我使Id与调整窗口时的内部高度相同吗? 这是代码
function height() { var h = window.innerHeight; document.getElementById("id").style.height = h+'px'; } height();This far i have succeded to make an Id to have same innerHeight as the window. However when i resize the window the height stays the same.
Could anyone help me make the Id be the same innerHeight as the window whenever it is resized ? Here is the code
function height() { var h = window.innerHeight; document.getElementById("id").style.height = h+'px'; } height();最满意答案
这种方法可能会对现有的事件处理程序更好:
window.addEventListener('resize',function(){ document.getElementById("id").style.height = window.innerHeight + 'px'; });this approach might play nicer with existing event handlers:
window.addEventListener('resize',function(){ document.getElementById("id").style.height = window.innerHeight + 'px'; });更多推荐
Id,height,innerHeight,window,窗口,电脑培训,计算机培训,IT培训"/> <meta name=&qu
发布评论