473,391 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,391 software developers and data experts.

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 16858
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.