Adjust scroll-content height onload

I am trying to adjust the scroll content when the view loads as sometimes it doesn’t do this. Why does this not work?

ionViewDidLoad() {
      
       window.onload = function(){
       
       var scrollContent =  <HTMLElement>document.querySelector(".scroll-content");
      
       scrollContent.style.marginTop = 300+'px';
       
     }