How can I close a browser window without receiving the Do you want to close this window prompt?
The prompt occurs when I use the window.close(); function.
How can I close a browser window without receiving the Do you want to close this window prompt?
The prompt occurs when I use the window.close(); function.
In the body tag:
<body onload="window.open('', '_self', '');">
To close the window:
<a href="javascript:window.close();">
Tested on Safari 4.0.5, FF for Mac 3.6, IE 8.0, and FF for Windows 3.5
From here:
<a href="javascript:window.opener='x';window.close();">Close</a>
You need to set window.opener to something, otherwise it complains.
The browser is complaining because you're using JavaScript to close a window that wasn't opened with JavaScript, i.e. window.open('foo.html');.