By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Can I focus a popup window without refreshing it?

P: n/a
The crux of the problem is I only know if the popup *has been* opened,
but not if it *is* open. Therefore, the script doesn't know whether to
simply refocus, or whether to popup a fresh window.

Are these the only solutions?
* handle onerror in some creative way
* hidden frames

BTW, I do have the luxury of ignoring non IE 5.5+ browsers on this
project, if it helps.

Thanks,
Jamie
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jamie Jackson wrote:
The crux of the problem is I only know if the popup *has been* opened,
but not if it *is* open. Therefore, the script doesn't know whether to
simply refocus, or whether to popup a fresh window.

Are these the only solutions?
* handle onerror in some creative way
* hidden frames

BTW, I do have the luxury of ignoring non IE 5.5+ browsers on this
project, if it helps.

Thanks,
Jamie


Just attempt to window.open() with the same window name (2nd parameter).
If the window is open, the new URL will load in it, if it's not open, it
will open a new window with that name.

These will open in the same window:
<a href="#" onclick="window.open('http://www.yahoo.com',
'theWindow');return false;">Yahoo</a>
<a href="#" onclick="window.open('http://www.microsoft.com',
'theWindow');return false;">MS</a>
<a href="http://www.ebay.com" target="theWindow">eBay</a>

These will open in a different window:
<a href="http://www.cnn.com" target="_blank">CNN</a>
<a href="#" onclick="window.open('http://www.msnbc.com',
'someOtherWindow');return false;">msnbc</a>

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

P: n/a
On Wed, 24 Sep 2003 19:57:04 GMT, Grant Wagner
<gw*****@agricoreunited.com> wrote:
Jamie Jackson wrote:
The crux of the problem is I only know if the popup *has been* opened,
but not if it *is* open. Therefore, the script doesn't know whether to
simply refocus, or whether to popup a fresh window.

Are these the only solutions?
* handle onerror in some creative way
* hidden frames

BTW, I do have the luxury of ignoring non IE 5.5+ browsers on this
project, if it helps.

Thanks,
Jamie


Just attempt to window.open() with the same window name (2nd parameter).
If the window is open, the new URL will load in it, if it's not open, it
will open a new window with that name.

These will open in the same window:
<a href="#" onclick="window.open('http://www.yahoo.com',
'theWindow');return false;">Yahoo</a>
<a href="#" onclick="window.open('http://www.microsoft.com',
'theWindow');return false;">MS</a>
<a href="http://www.ebay.com" target="theWindow">eBay</a>

These will open in a different window:
<a href="http://www.cnn.com" target="_blank">CNN</a>
<a href="#" onclick="window.open('http://www.msnbc.com',
'someOtherWindow');return false;">msnbc</a>


Thanks for the reply. Unfortunately (unless I missed something), I
don't think the question (of how to keep the popup from refreshing)
has been addressed.

Here's why I'd prefer that it didn't refresh: I've got a good bit of
content (help files) in the popup, and I don't want to lose the scroll
position, since the user might be in the middle of reading something,
they click on the parent, and they want to go back to the popup (by
re-clicking the help link from the parent). It would be nice if I just
refocused that window the next time the "help" link was clicked,
instead of reloading the URL into that window, and starting from
scratch.

Any ideas?

Thanks,
Jamie

Jul 20 '05 #3

P: n/a
Jamie Jackson wrote:
how to keep the popup from refreshing
window.closed may provide the answer:
var hwin=null;

function showHelp(href)
{
if(hwin && !hwin.closed)
hwin.focus();
else
hwin=window.open(href,"help_win");
}

.....

<a href="help.html"
onclick="showHelp(this.href);return false;" help </a>

The closed property was introduced in javascript 1.1, and although not
standardised is widely implemented. For further information on
downloading Netscape documentation for Javascript 1.3, please consult
the NG FAQ

Dom
========
http://www.jibbering.com/faq/#FAQ3_2
Jul 20 '05 #4

P: n/a
Hmm, I'll play with that. Thanks!

Jamie

On Fri, 26 Sep 2003 10:42:47 +0930, Dom Leonard
<do*************@senet.andthis.com.au> wrote:
Jamie Jackson wrote:
how to keep the popup from refreshing


window.closed may provide the answer:
var hwin=null;

function showHelp(href)
{
if(hwin && !hwin.closed)
hwin.focus();
else
hwin=window.open(href,"help_win");
}

....

<a href="help.html"
onclick="showHelp(this.href);return false;"
> help </a>

The closed property was introduced in javascript 1.1, and although not
standardised is widely implemented. For further information on
downloading Netscape documentation for Javascript 1.3, please consult
the NG FAQ

Dom
========
http://www.jibbering.com/faq/#FAQ3_2


Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.