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.
This my component
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();
}
}
}
In above code
popup.onload=function(){
alert("Hello");
window.close();
}
is not working, there is no alert and also window didn't got close. but if I just do
popup.alert("Hello");
popup.close();
It work's. But I want to close the window when the whole URL got load i.e on onload() function.
Please provide some pointer regarding this issue.
Thanks in advance!