Forum Moderators: open
After sending an email message, a new window shows saying thank you and provides a button to close. Easy, eh?
Well, what's wrong with the code below, and why don't either of the buttons actually close the window?
I tried self.close, parent.window.close, top.window.close : nothing seems to fire.
Using Firefox to test.
Thanks for helping this brain-cramped old man! :-)
<html>
<head>
</head>
<body>
<table width="370px" align="left">
<tr><td>
<h3 align="center">Thank You for your interest in our services.</h3>
<p align="center">We will contact you via your preferred method within three business days</p>
</td></tr>
<tr><td>
<p> </p>
</td></tr>
<tr><td>
<p align="center"><input type="button" onClick="javascript:window.close();" value="Close Window"></p>
</td></tr>
<tr><td>
<form method="post">
<input type="button" value="Close Window" onClick="window.close();">
</form>
</td></tr>
</table>
</body>
</html>
But if you use some scripting method to open a new window
var win=open('test.html','123456','width=400,height=500,scrollbars');
Then window.close() will work to close test.html. if you directly open test.html, it will warn you, or not close it at all.
Imagine if this security feature were not in place: you visit a site, and they close all your referring windows, pop up all their ads and effectively suck your entire computer into an internet black hole. :-)
But there's maybe something I'm not being clear about.
The window I provided as example is not attempting to close any other window, and does not automatically try to even close itself.
I am suggesting that it should be possible for a user to click on the button on an open window, and have that same window close *just like they can if they click on the charming little X in the top right corner*.
There is certainly no security issue here at all, as the operation being performed is no different from operations that are available to the user normally.
20 years of programming suggest to my addled brain that this is not asking very much.
So are people trying to tell me that HTML does not permit such a button, which is manually fired by the user?
I'm not trying to be rude or obtuse, but what unscripted method can I use to effect this operation?