Scriptplayground

 Print Page | Close Window

Javascript Popup

A javascript popup that reuses the popup window once it is opened.

<script type="text/javascript">
<!--

function myOpenWindow(winURL, winName, winFeatures, winObj)
	{
	var theWin;
	if (winObj != null)
		{
		if (!winObj.closed) 
			{
			winObj.focus();
			return winObj;
			}
		}
	theWin = window.open(winURL, winName, winFeatures);
	return theWin;
	}

var myWin = null;

//-->
</script>

This is a code snippet that creates a popup and reuses the window once it is opened

<a href="http://www.google.com" onclick="myWin=myOpenWindow(this,
'Window Name','height=400,width=300,scrollbars=no',myWin); return false">Example Link</a>

Here is an example use of the code


Find this article at:
http://scriptplayground.com/tutorials/js/Javascript-Popup/