Close window

This isn't actually a ColdFusion tutorial, but many ppl. have ask how they easy can put a link or button on a page to 'Close a window'. This can be done by using a JavaScript link.
Example:
<a href="javascript: window.close();">Close this window</a>

This will open a dialog box. The Web page you are viewing is trying to close the window.
Do you want to close this window? Yes/No

The next script closes the window automatic.

<a href="javascript:window.close();">Close This Window</a>
<br>
<form>
<input type=button value="Close This Window" onClick="javascript:window.close();">
</form>


Below is an example of a pop up window that will close automatically after a time period.
Define the time period in the variable "howLong".  Example: 5000 milliseconds, 7000 milliseconds and so on.

<HTML>
<HEAD>
<TITLE>Auto close pop up window </TITLE>
<SCRIPT>
   var howLong = 5000;
   t = null;
   function closeMe(){
   t = setTimeout("self.close()",howLong);
   }
   </SCRIPT>
</HEAD>
<BODY TEXT="#000000" onload="closeMe();self.focus()">
<TABLE ALIGN="center" WIDTH="300">
  <TR>
    <TD ALIGN="center"><P ALIGN="center"><B>This window will close in 5 seconds!</B> </TD>
  </TR>
</TABLE>
</BODY>
</HTML> 

Advertisement

Hot Offers

User Comments: 2

 close window

Example:

<a href="javascript: window.close();">Close this window</a>

This will open a dialog box. The Web page you are viewing is trying to close the window.
Do you want to close this window? Yes/No

The next script closes the window automatic.

<a href="javascript:window.close();">Close This Window</a>
<br>
<form>
<input type=button value="Close This Window" onClick="javascript:window.close();">
</form>
..............................................................................

This script does not close the window "automatic",
the user must still press the -close this window-
button, which is no easier than pressing yes on the
original dialog box !

 close window

Example:

<a href="javascript: window.close();">Close this window</a>

This will open a dialog box. The Web page you are viewing is trying to close the window.
Do you want to close this window? Yes/No

The next script closes the window automatic.

<a href="javascript:window.close();">Close This Window</a>
<br>
<form>
<input type=button value="Close This Window" onClick="javascript:window.close();">
</form>

This does not close the window "automatic",
the user must still press the -close this window-
button, which is no easier than pressing yes on the
original dialog box !

ApplayIT is owned by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.