View Full Version : Bring target window to front.

Vijay Venkat
04-24-2007, 09:06 PM
I have a anchor whose target is set to value "myWin" . When the user clicks, the anchor element's href is set. The page comes up well as specified in the target.

The actual situation is that there are many links. All links point to the same target. When the user clicks, the page comes up fine, but it remains at the back of the original page. How to get it the front?

Here is the code which simulates the problem. The problem can be seen clearly in fire fox.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> New Document </title>
var i = 0;
var link= new Array("http://www.yahoo.com", "http://www.google.com", "http://www.webmonkey.com");
function testTargetOnAnchor(linkId)
var elm = document.getElementById(linkId);
if (i > 2)
i = 0;
elm.href= link[i];

<li onclick="testTargetOnAnchor('linkId');"><a id="linkId" href="" target="myWin">Window Example</a>

Click on the link first time and wait for new page to be loaded.
After this again click, on the link, the already opened page is refreshed with the current url, but it remain in the back.

It is possible to get handle to this window object and set focus to it?

Here the window is "myWin" - it is specified as the target of the anchor tag.

<a id="linkId" href="" target="myWin">Window Example</a>

Any pointers would be really appreciated.