I have two web pages. First.html:
<script> window.onload = function(){ setTimeout(loadAfterTime, 3000) }; function loadAfterTime() { my_window = window.open("Second.html", "","status=1,width=100%,height=100%");}
this.window = previous_window ;
</script>
Second.html:
<html>
<head>
<script>
function closepopup()
{
if(false == previous_window.closed)
{
previous_window.close ();
}
else
{
alert('Window already closed!');
}
}
</script>
</head>
<body>
<button onclick="closepopup();">
Close
</button>
</body>
</html>
If we load first.html in a browser, after 3 seconds of load, the JavaScript will make a browser window with the URL set into Second.html.
I have added a button in the second.html file.
If we press that button, I want to delete/remove the previous browser window (first.html).
The window.open
is working button window.close
is not.
Please help.
Also, the code should perfectly work on mobile devices(Latest Chrome app on Android and IOS).
Any help will be appreciated.