< Back

Document Subject: Javascript: Make browser window jump to the front on loading - now with firefox 2.0 fix
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#FocusWindow or http://A555F9/nn.nsf/ByAlias/FocusWindow

Bring Pop up Window to the front in javascript. This works in ie but not firefox 2.0. I have a way arounds firefox 2.0 security.

This is a simple bit of code to redisplay the window to the user.

Especially useful on large or slow webpages.

<script> window.focus(); </script>

This code can also be used in dialog boxes, to bring the dialog box to the front if it is redisplayed.

If in doubt stick it at the end of your form design of web Dialogue Boxes.

 

Update 1st May 2007:  This doesn't work in Firefox 2.0 because firefox have changed the window permissions, I can sort of understand it but it is very annoying. I have not found a work around.

The only way around it is to always pop up in a brand new window each time.

If you have a call that pops up details in a new window, you could have had window.focus() in there and the window would just reload and pop up again to the front, to make it work in firefox I add the time to the window name:

Stamp = new Date();
javascript:void(open('http://AdFos.com',  'Photo'+Stamp.getHours()+Stamp.getMinutes()+Stamp.getSeconds()+Stamp.getMilliseconds(), 'height=500,width=500,screenX=200,screenY=300,top=' +(iWinY-10)+',left='+(iWinX+10)+',resizable=yes,location=no,scrollbars=no,menubar=no,toolbar=no,directories=no'));

This creates lots of windows, but at least the user can see them!

Alternatively use

var w = window.open ("url","winName","location=0,width=300,height=214");
w.focus();