我在网站上有以下代码:
window.onload = resize;
window.onresize = resize;
function resize(){
heightWithoutHeader = (window.innerHeight - 85) + "px";
document.getElementById("main-table").style.height = heightWithoutHeader;
document.getElementById("navigation").style.height = heightWithoutHeader;
}
onresize
工作正常,但 onload
事件永远不会触发。我已经在 Firefox 和 Chrome 中试过了,但它们都不起作用。
感谢您的帮助,并为声誉而努力! ;D
原文由 user321068 发布,翻译遵循 CC BY-SA 4.0 许可协议
我认为这里可能发生的是你的
window.onload
稍后被覆盖,检查以确保它不是通过类似<body onload="">
您可以在调整大小功能中通过
alert(window.onload)
检查它,以查看实际附加的内容。