Use Only One Popup

[Total: 0    Average: 0/5]

This code will open up popups all the same window.

Body Code:

<script>
var _start="<HTML><HEAD><TITLE>My Page</TITLE></HEAD><BODY onunload='opener._win=null;'>";
var _end="</BODY></HTML>";
var _page=new Array();
    _page[1]=_start+"One is a lonely number."+_end;
    _page[2]=_start+"Two is a nice pair"+_end;
    _page[3]=_start+"Three often leaves out one - isn't that lonely"+_end;
var _win=null;
function closeWin()
{
  if(_win && !_win.closed && _win.open)
  {
      _win.close();
	  _win=null;
  }
}
function openWin(i)
{
  closeWin();
  _win=window.open();
  _win.document.open();
  _win.document.write(_page[i]);
  _win.document.close();
  _win.focus();
}

</script>
<a href=javascript:openWin(1)>click to open window #1</a><BR>
<a href=javascript:openWin(2)>click to open window #2</a><BR>
<a href=javascript:openWin(3)>click to open window #3</a><BR>

<!--
the code that follows is here only to show what needs to be in the body tag
-->
<HR>
&lt;body onload=closeWin() onfocus=closeWin()&gt;

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *