tags:

views:

38

answers:

2

I know how to open a small window:

function SmallWindow(theURL,winName)
  {window.open(theURL,winName,'toolbar=yes,scrollbars=yes,
menubar=yes,toolbar=yes,resizable=yes,width=800,height=500,left=300,top=200');}

being called as

<a href="http://newURL.html" onclick="SmallWindow(this.href, ''); return false">
  Click here</a>

The problem is that with many clicks in various links of a big window this produces a sequence of different small windows. I want all those small windows overlapping each other on the same window. I tried to give a window name, WIN

function SmallWindow(theURL,winName)
{window.open(theURL,"WIN",'toolbar=yes,scrollbars=yes,menubar=yes,toolbar=yes,
resizable=yes,width=800,height=500,left=300,top=200');

but when a new small window is opened, the browser does not jump to it, and the user does not get aware that the new small window was opened!

I could not find an answer to this problem. Thanks for any help.

A: 

I think you can bring the popup window to the from like this:

var newWin = window.open(url, "WIN", ...);
newWin.focus();

As you already found out, it is important to always use the same window name (e.g. "WIN"). Otherwise a new window will be opened with every window.open() call.

The focus() method will then bring the window to the front.

M4N
Dear Martin and AJ,Thank you very very much for your useful advices. They worked beautifully! I really appreciate your effort. All the best, Val Setzer.
+1  A: 

The call to window.open will return a reference to the new window (or existing window in the case where a window with the same name is already open). You can then call the focus() method on that window to bring it to the front.

function SmallWindow(theURL, winName)
{
  var myWindow = window.open(theURL, winName,'toolbar=yes,scrollbars=yes,menubar=yes,toolbar=yes, resizable=yes,width=800,height=500,left=300,top=200');
  myWindow.focus();
}
AJ