473,473 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Focus() window by Name NOT Reference

N/A
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
something like windows['popup'].focus()

I know you can set a variable to the window reference when you open the
popup ie( var x = window.open(); ) but this is not suitable in my
particular case. I need to be able to gain access to the window object
without having its direct reference...

Thanx
Jul 20 '05 #1
2 16863
DU
N/A wrote:
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');

You need to remove all blank spaces in the 3rd parameter string list.

"windowFeatures is an optional string containing a comma-separated list
of options for the new window (do not include any spaces in this list)."
http://devedge.netscape.com/library/...w.html#1202731

Btw, why do you turn off the statusbar and remove the resizability of
the popup?
Then I know that there is a window object in the windows collection called
'popup'.
No. That's just a property of string type; it's not a window object
reference (pointer in memory).

So how can I make that window come to the front? Looking for something like windows['popup'].focus()

var WindowObjectReference ; // needs to be a global variable

function OpenRequestedPopup()
{
if(WindowObjectReference == null || WindowObjectReference.closed)
{
WindowObjectReference = window.open("http://www.google.com", "popup",
"width=618,height=425,resizable=yes,scrollbars=yes ,status=yes");
}
else if(!WindowObjectReference.closed)
{
WindowObjectReference.focus();
};

I know you can set a variable to the window reference when you open the
popup ie( var x = window.open(); ) but this is not suitable in my
particular case.
Why? Please elaborate.

Let me underline that the successful use of focus() implies that
javascript is enabled on the remote system. So trying to use the focus()
method on an opened secondary window by a target attribute with js
disabled cannot work.

I need to be able to gain access to the window object without having its direct reference...

Thanx


Then it's impossible. focus() is a method for a window object reference:
therefore you need a direct reference to it, a pointer in the memory heap.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #2
N/A
Thanks Laurent, perfect :)
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F1247D2.2000805@bluewin_NO_SPAM.ch...
Hi,

N/A wrote:
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
something like windows['popup'].focus()

I know you can set a variable to the window reference when you open the
popup ie( var x = window.open(); ) but this is not suitable in my
particular case. I need to be able to gain access to the window object
without having its direct reference...

Thanx
You should always keep a reference (the 'x' in your example) to your
windows, but I can imagine cases where you really don't have access to
it. In these rare cases, you can gain a new reference to the opened
window with:

var newX = open( '', 'popup', '' );

After that, you can work with it like with a normal reference, for

example:
newX.focus();

Note however that this will open a new blank window if popup was
previously closed by the user. If you don't keep a reference on this
window somewhere (for example in a frameset), you have no way to know it
the window is still open or not.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #3

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

Similar topics

1
by: Diana | last post by:
Hi there, I'm having some difficulty in renaming a window object. I'm opening the window in question via a targetted submit: <!-- CODE EXCERPT FROM WINDOW 1 --> <form target="newWin"> ...
1
by: Tony Farrell | last post by:
Hi Everyone - I have a data entry form that allows the user to click a button and have that button popup a list of available values - the code on the popup window uses the name of the form to...
4
by: Cenekemoi | last post by:
Hi, excuse me in advance for my poor english... Do you know how solve my problem ? I have "Page1.htm" : <HTML><BODY> <A href="Page2.htm" target=TOTO>window TOTO</A>
2
by: er441298 | last post by:
we are upgrading an application which is JS heavy to run on IE6. When in IE 5.0, and when the following command is executed on a child window (top.window.name), it returns an actual window ID ( a...
1
by: atlas | last post by:
Hello eveybody Here's my problem: I have 2 files: File A.html: ----------------> <script> window.name='test';
6
by: Kiran | last post by:
Hi, I am opening a popup window using the code given below window.open("test.aspx","EmployeeDetails"). how to get the window name("EmployeeDetails") in the new opened window test.aspx using...
2
by: Kiran | last post by:
Hi, can anyone tell me how to get window name on server side using asp.net(similar to window.name or self.name in clientside) Thanks Kiran
5
by: mikewse | last post by:
I'm having a strange problem with window.name (from JavaScript) on *some* of our computers. OS is Windows 2000 so Internet Explorer version is IE6 sp1. I really need some help here... We are using...
1
by: bytesuser | last post by:
I'm trying to send a list of objects to a new window by reference, but get a compiler error saying my new window "does not contain a constructor that takes '1' arguments" Here's my constructor in...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.