0

I'm using a form with submit button in html which opens a new window onclick of submit. Now i want this new window to be closed without user intervention.

i have tried below:

<script type="text/javascript">
var newWin;
function newWindow()
{
    alert('in newWindow');
    newWin=window.open('http://someurl','_blank');
    setTimeout(function(){newWin.close()}, 10);
    alert('closed..');
}
</script>

but this does seem to close the new window. It still stays open. Pls help.

Anu
  • 176
  • 1
  • 3
  • 14

1 Answers1

0

Your Code is working Fine, only thing is you need to give some time to see that window, alert boxes not required

<script type="text/javascript">
var newWin;
function newWindow()
{
    newWin=window.open('http://www.google.co.in','_blank');
    setTimeout(function(){newWin.close()}, 5000);
}
</script>
<button onclick="newWindow()">open Window</button>
Keerthivasan
  • 1,651
  • 1
  • 21
  • 47
  • Marking this as the answer, though my problem lies with the proxy for the URL as @guest271314 pointed out. – Anu Oct 05 '16 at 07:17