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!

Changing window focus

Status
Not open for further replies.

jsolutions

Programmer
Jul 18, 2002
157
US
I want to do something that I thought would be fairly easy. When my index.html page opens, I am opening another page that has content that takes a while to load. I am using the code below.
Code:
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow')
-->
</SCRIPT>
This opens a new window with the content. However, the problem is that I then want the focus to go back to index.html. I have tried using self.focus() after the window.open, but whether I use that or not, it seems to throw the focus to the new window.

How can I regain focus to index.html?? Any help would be greatly appreciated.

Thanks
 
what you might want to do it add the following to your "page.html" to return the focus back to the main window
Code:
<script type="text/javascript">
window.onload=window.opener.focus();
</script>
This way the popup returns the focus instead of the index page trying to keep the focus.

Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Hi Einstein - thanks so much for the reply. One follow up question. Is there anyway to ONLY trigger this if "page.html" is opened from the window.open command?? In other words, if I have a page "xyz.html" that simply has a link to "page.html" (rather than using window.open), I would not want this to occur. Is that possible? In other words, I want to have the best of both worlds??

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top