Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: JavaScript
Expertise: Beginner
Oct 18, 2005



Application Security Testing: An Integral Part of DevOps

Closing a Popup Window Automatically

The following code will close a popup window after the user selects to download the file, or if he/she cancels the download.

Between the <head></head> tags of the document is popped up, add the code below:

<script language="JavaScript">
	function checkVar()	{
		if(document.frm.winFocus.value==1)	{
	function changeVar()	{
In the <body> tag add this:

<body onFocus="checkVar();">
Somewhere in the body of the document add:

<form name="frm">
	<input type="hidden" name="winFocus" value="0">
And finally wherever you need them, the links:

<p class="normal">Download ?
	<a href="fileToDownload.zip" onClick="changeVar();" class="zipLink">Yes</a>  
	<a href="javascript:;" onClick="window.close();" class="zipLink">No</a></p>

Note: This works for both Internet Explorer and FireFox.

Konstantinos Lagos
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date