title: window.onload not working in angular 4
body: <p>I want to open a new window popup and as soon as the URL got load in the new popup window I want to close it.</p>
  
  <p>This my component</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent implements OnInit{
    title = 'app';
  
    ngOnInit():void{
      var popup=window.open('https://www.w3schools.com','newwindow','width=300,height=200');
      popup.onload=function(){
        alert("Hello");
        window.close();
      }
    }
  }
  </code></pre>
  
  <p>In above code</p>
  
  <pre><code>popup.onload=function(){
     alert("Hello");
     window.close();
   }
  </code></pre>
  
  <p>is not working, there is no alert and also window didn't got close.
  but if I just do </p>
  
  <pre><code>popup.alert("Hello");
  popup.close(); 
  </code></pre>
  
  <p>It work's. But I want to close the window when the whole URL got load i.e on onload() function.</p>
  
  <p>Please provide some pointer regarding this issue.</p>
  
  <p>Thanks in advance!</p>