Close current window (button)

Information on ASP, ASP.NET, PHP, HTML, Javascript and anything else WWW related.

Close current window (button)

Postby Buck on Tue Nov 04, 2008 8:32 pm

Sometime you have a popup windows that will explain something or give a definition and you want to add a button for the user to close the current window.

This will produce a text link that, when clicked, will close the current browser window:

Code: Select all
<a href="javascript:self.close()">Close the window</a>


produces:

Close the window (in text format)

If the current window is the original window opened by the user, the user will see a prompt asking whether it's ok to close the window.

Here's another one that works w/ a button instead of text:
Code: Select all
<INPUT Type="button" Value="Close Window" onClick="window.close();">
User avatar
Buck
 
Posts: 22
Joined: Wed Oct 29, 2008 10:25 pm

Return to Web Site Assistance

Who is online

Users browsing this forum: No registered users and 1 guest

cron