Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I close a browser without prompting the user?

HTML: How To...

How do I close a browser without prompting the user?

by  skiflyer  Posted    (Edited  )
This code is actually javascript, but the question comes up often in this forum, and I don't take credit for the solution, but I thought it might be a good place to have it.

Code:
<script type="text/javascript" language="javascript">
function bye() {
  self.opener=this;
  self.close();
}
</script>

Enjoy!

As per a suggestion, I'll be a bit more explicit... this function should be placed in whichever window it is you want to close, and then be called as a simple
bye();

i.e.

<input type="button" name="close" value="Close the page" onClick="bye();" />


As fair warning, this is not fully javascript compliant, fully compliant browsers will tell you that you can not close a window which you did not open with the script. However, since Microsoft defines it's own standards, this works in IE 6 until they decide to change it.

-Rob
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top