JavaScript event [removed] not triggered

2019-03-14 06:40发布

I've got the following code in a website:

 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;
 }

The onresize works fine, but the onload event never fires. I've tried it in Firefox and Chrome and neither of them works.

Thank you for your help and go for the reputation! ;D

7条回答
Anthone
2楼-- · 2019-03-14 07:41

If it's really in that order, it's definitely not going to work. You can't assign a function to an event handler before the function itself is declared.

查看更多
登录 后发表回答