Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

focus of windows

Status
Not open for further replies.

secretsquirrel

Programmer
Mar 22, 2001
202
GB
Hi guys,

I posted a similar problem here a couple of days ago, but the plot thickens...

I have a page containing a set of links to external sites which are out of my control (Yahoo, Google, etc.). If a user clicks on, for example, Yahoo, it is launched in a new window.

After using Yahoo, the user might leave the Yahoo window open and return to the original window. If they then click on Google, it is launched in the Yahoo window, but this remains out of focus.

How can I get the new window to regain focus every time a new site is loaded into it?

I know that I could use a frameset (one for each link) consisting one frame which contains the site, and use onLoad="window.focus()", but my site gives users the option of personalising the set of links.
 
This is what you do

when you open the window, assign it to a variable. You then have full access to the window through the variable:

<SCRIPT>
function myopen(url){
mywind=window.open(url,'stephens_window');
mywind.focus();
}
</SCRIPT>



Stephen
 
Thanks a lot stephence,

I used your function and realised that if the window is instantly given the focus, it appears on screen still displaying it's previous page.

So, I changed:

mywind.focus();

to:

setTimeout(&quot;mywind.focus();&quot;, 2500);

and you get a 2.5 second delay to give the new URL a bit of time to load.

Thanks again,

SS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top