473,748 Members | 11,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

focus on the new window.open window

Up until a few weeks ago, javascript code like

window.open("ht tp://mydomain.com", "windowName ");

would always bring my new or reused window to the top, with focus.
Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).

Is there a new way in Mozilla/Firefox that I can ensure that this
window
comes to the top?

Thanks,
Csaba Gabor from Vienna

Nov 30 '05 #1
4 3601
Csaba Gabor wrote:
Up until a few weeks ago, javascript code like

window.open("ht tp://mydomain.com", "windowName ");

would always bring my new or reused window to the top, with focus.
Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).
I do not think there is a significant change here. It is well-known
that reused windows are not always and everywhere focused.

However, Firefox 1.5 is out now, so I do not think Deer Park _alphas_
do really matter anymore. (I have not installed Firefox 1.5 yet.)
Is there a new way in Mozilla/Firefox that I can ensure that this
window comes to the top?


You could call the focus() method of the respective Window object
after it has been established on runtime that there are both:

function isMethodType(s)
{
return (s == "function" || s == "object");
}

var w = window.open(... );
if (w && !w.closed && isMethodType(ty peof w.focus))
{
w.focus();
}
PointedEars
Nov 30 '05 #2
Csaba Gabor a écrit :
Up until a few weeks ago, javascript code like

window.open("ht tp://mydomain.com", "windowName ");

would always bring my new or reused window to the top, with focus.
No. Only new windows.
Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).
No. Check again carefully. IE 6 does not bring back on top an already
used window.

Is there a new way in Mozilla/Firefox that I can ensure that this
window
comes to the top?


This is already well explained at:

http://developer.mozilla.org/en/docs...Best_practices

Gérard
--
remove blah to email me
Dec 1 '05 #3
Gérard Talbot wrote:
Csaba Gabor a écrit :
Up until a few weeks ago, javascript code like
window.open("ht tp://mydomain.com", "windowName ");
would always bring my new or reused window to the top, with focus.


No. Only new windows.
Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).


No. Check again carefully. IE 6 does not bring back on top an already
used window.


Lee, PointedEars, and Gérard, thank you for your reply.
My apologies because Gérard is correct in what he writes above.
Indeed, I had left out that I was doing a subsequent .focus(),
which had been working well on both IE and FF till about two
weeks ago on FF:

var myWin = window.open("ab out:blank", "_Result");
myWin.focus();
Is there a new way in Mozilla/Firefox that I can ensure that
this window comes to the top?


This is already well explained at:

http://developer.mozilla.org/en/docs...Best_practices


I'm familiar with those pages on the window object, and they are quite
well done. I especially appreciate the diagram covering the naming of
various items on the page, and the explanations for all the
properties/methods/events.

However, the behaviour I am experiencing is not covered there. The
version of Firefox that I have (1.6a1 = Deer Park alpha 2) has new
"features" restricting this behaviour by default, it seems.
Specifically, if, in Firefox, I go to Tool / Options / Conent tab /
Enable Javascript is checked / Advanced button (to the right of Enable
Javascript), then I get a dialog box listing 5 checkbox buttons:
Move or resize existing windows
Raise or lower windows
Disable or replace context menus
Hide the status bar
Change the status bar text

Unfortunately, automatic update unchecked both of the top two options
for me. .focus() has no effect if Raise or lower windows is not
checked. Frankly, it seems wrong for automatic update to have changed
my settings without any warning, but even moreso, I would not expect
this behaviour to apply to a parent-child window. I would expect that
related windows can alter their relative Z-indexes. Otherwise you get
the really bad situation where one page changes another (consider a web
app writing to an output window) and the user has to cycle through a
boatload of windows to find it, assuming that he's aware that it might
have changed at all. Not a good situation in the least.

In addition, there is the grossly brute force approach of writing the
window once to get ownership and a reference to it, closing the window,
then opening it for real. This is also not very nice because prior
repositioning/resizing information that the user may have set is lost
in addition to extra bandwidth, thrashing.

// picking a unique name effectively guarantees this
// window, if it exists, was opened by script. And if
// it didn't exist before, it does now
var myWin = window.open("ab out:blank", "_Result");
// So we close it
myWin.close();
// to ensure the following line brings it to the top
myWin = window.open("ab out:blank", "_Result");
// even when .focus() is disabled
myWin.focus();

Csaba Gabor from Vienna

Dec 1 '05 #4
Csaba Gabor a écrit :
Gérard Talbot wrote:
Csaba Gabor a écrit :
Up until a few weeks ago, javascript code like
window.open( "http://mydomain.com", "windowName ");
would always bring my new or reused window to the top, with focus.
No. Only new windows.

Lately, Firefox (Deer park alpha 2) only brings it to the top if the
window is new. If it's being reused, the window does not come to
the foreground (with IE 6 it does).


No. Check again carefully. IE 6 does not bring back on top an already
used window.

Lee, PointedEars, and Gérard, thank you for your reply.
My apologies because Gérard is correct in what he writes above.
Indeed, I had left out that I was doing a subsequent .focus(),
which had been working well on both IE and FF till about two
weeks ago on FF:

var myWin = window.open("ab out:blank", "_Result");
myWin.focus();

Is there a new way in Mozilla/Firefox that I can ensure that
this window comes to the top?


This is already well explained at:

http://developer.mozilla.org/en/docs...Best_practices

I'm familiar with those pages on the window object, and they are quite
well done. I especially appreciate the diagram covering the naming of
various items on the page, and the explanations for all the
properties/methods/events.

However, the behaviour I am experiencing is not covered there. The
version of Firefox that I have (1.6a1 = Deer Park alpha 2) has new
"features" restricting this behaviour by default, it seems.
Specifically, if, in Firefox, I go to Tool / Options / Conent tab /
Enable Javascript is checked / Advanced button (to the right of Enable
Javascript), then I get a dialog box listing 5 checkbox buttons:
Move or resize existing windows
Raise or lower windows
Disable or replace context menus
Hide the status bar
Change the status bar text

Unfortunately, automatic update unchecked both of the top two options
for me. .focus() has no effect if Raise or lower windows is not
checked. Frankly, it seems wrong for automatic update to have changed
my settings without any warning, but even moreso, I would not expect
this behaviour to apply to a parent-child window. I would expect that
related windows can alter their relative Z-indexes. Otherwise you get
the really bad situation where one page changes another (consider a web
app writing to an output window) and the user has to cycle through a
boatload of windows to find it, assuming that he's aware that it might
have changed at all. Not a good situation in the least.

Speak up where it counts:
https://bugzilla.mozilla.org/show_bug.cgi?id=299424#c7
"(2) Raise or lower windows
Should be disallowed by default. (...)"
I have right here:
https://bugzilla.mozilla.org/show_bug.cgi?id=299424#c8
and also
http://www.gtalbot.org/Netscape7Sect...seLowerSetting

In addition, there is the grossly brute force approach of writing the
window once to get ownership and a reference to it, closing the window,
then opening it for real.
Very bad approach that I have denounced already/before.

This is also not very nice because prior repositioning/resizing information that the user may have set is lost
in addition to extra bandwidth, thrashing.
The bandwidth "cost" is more important that the repositioning. If the
position (screenX, screenY, left or top coordinates) have not been
defined, then the new window is positioned at the coordinates of the
last opened non-maximized window: error compensation/correction
mechanism to sanitize position will apply.

// picking a unique name effectively guarantees this
// window, if it exists, was opened by script.
I wouldn't say that. Using an unique name is very helpful in trying to
recycle, to reuse an already opened window, though.

And if // it didn't exist before, it does now
var myWin = window.open("ab out:blank", "_Result");
You can't start a window name with "_". Invalid.
// So we close it
myWin.close();
Default value of
dom.allow_scrip ts_to_close_win dows
is false in Firefox 1.5. So, you can not just close a window, just like
that.
// to ensure the following line brings it to the top
myWin = window.open("ab out:blank", "_Result");
// even when .focus() is disabled
myWin.focus();


Gérard
--
remove blah to email me
Dec 1 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16902
by: N/A | last post by:
Hey all, If I open a popup like this window.open('http://www.google.com', 'popup', 'width = 618, height = 425, directories = no, location = no, menubar = no, resizable = no, scrollbars = yes, status = no, toolbar = no'); Then I know that there is a window object in the windows collection called 'popup'. So how can I make that window come to the front? Looking for
2
4224
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing windows to the front (top) in Netscape, IE and Opera. However, this command does nothing when you access the web page through AOL, even though they say this is IE. Once a window is behind (blurred), I have been unable to bring it back to the front...
31
2846
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page www.any.xy an setting the focus to "extern". But when I go return to "main" without closing "extern", a click to an other link (e.g. www.2nd_any.xy) on "main" does not setting the focus to "extern".
13
2273
by: Richard Shewmaker | last post by:
I've only recently returned to (trying to) doing simple JS, so this is probably a really lame question. I have a Web page with a series of graphics in it (window A). Clicking on a graphic in A opens a small pop-up window (window B) over A. If the visitor clicks on B, it closes. If the visitor clicks back on A -- the page or a new graphic -- A comes
11
7345
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz 1.7.12 (linux kubuntu). It does work with konqueror. It seems to work with firefox on windows but not with IE (not completly sure though).
7
13092
by: marty.overdear | last post by:
I am opening a new window using window.open. I need the new window to open on top of the parent everytime. I cannot use onBlur b/c the user will need to click back to the parent for information. I just need it to open on top everytime. I am using this line in the body <body onload="window.focus()" bgColor="#0077d6" ms_positioning="GridLayout"> The window.focus doesn't work everytime. I can open it and it may work. I will...
4
68046
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between these forms that may make one succeed and another fail? In particular, this.window.focus() fails in Opera 9.10 with an "object not found", and windows.focus() succeeds in Opera 9.10, Firefox 2.02, and IE 7.
4
4060
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the user looking at window A clicks the "open window B" link, I want
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.