Dev.Opera - Follow the standards, break the rulesDev.Opera - Follow the standards, break the rules

Login

Lost password?

Forums » General Discussions

General DevOpera discussion group

Note: You need to login to post in the forums. if you don't have an account you first need to sign up.

By chrisgcolby anchor Friday, 14. March 2008, 17:53:43

avatar

How to definitively determine if a popup window is still open?

I want to create a sort of "global access" help window popup that will be available to all of the web pages in my browser application. If it is created and left open by one file, then don't recreate it any other file, just shift focus. If it is created and dismissed, then recreate it.

I have declared a file-scope popup window variable (example: winPopup) in a file's (example: WebFile1.htm) JavaScript, and this variable is initialized to null onLoad. On window.open, I accept the popup when prompted by the Opera popup blocker, and my winPopup variable now points to this window object. I view the information in the popup, then dismiss this popup window.

The JavaScript in WebFile1.htm now sees that winPopup is not equal to null, AND that winPopup.closed == false. At this point, the WebFile1.htm's JavaScript also sees that winPopup.opera == undefined. (Sometimes it sees winPopup.opera == null.)

Further complications arise when you go to WebFile2.htm with the original popup window still open, and attempt to open a window with the same name as in WebFile1.htm. WebFile2.htm also contains its own file-scope popup window variable, also initialized to null onLoad.

In this case, I need the JavaScript in WebFile2.htm to somehow see the existing popup, AND get a pointer to it so that I can use that pointer to shift focus. Determining whether it is there, and that it is available, has been the tricky bit.

In IE and FireFox I just use the same name with an empty URL string in the window.open method. If a loaded object pointer comes back, then I set that pointer to my file-scope variable and use it. If a blank object pointer comes back, then I know to dismiss the blank window and create a new window using the real URL.

I appreciate that Opera is agressive on popup handling. However, for those of us who are not nefarious, and just want to create an application for our users, this is getting a bit tricky.

I have searched the forums on this, and I have found some small information which I have attempted to use in my own code. I am sure that a solution to this problem has been posted, but I can't find it.

My Questions:

1. Is there a way to definitively determine whether a popup created by Webfile1.htm and pointing to another host on the same domain is still open, and available to simply receive focus?

(Example: WebFile1.htm on www.mywebsite.com wants to open a popup into help.mywebsite.com/homepage.htm.)

Or whether it has been closed and needs to be re-created? If it is already open, I also do not want to direct this window to the home page, but just want to shift focus to this already open window and leave the user where they were when they last looked at it.

(Example: If the popup is already open, and the person has already navigated this popup to help.mywebsite.com/directory/detailfile.htm, I do not want to reload this popup so that it refreshes to help.mywebsite.com/homepage.htm)

2. Is there a way to definitively determine whether a popup created by WebFile1.htm, but now being accessed by WebFile2.htm, is open and available to simply receive focus? If so, how does it receive focus?

Again, if I determine that it is available, and I can get it to receive focus, I don't want the person to wind up getting re-directed to help.mywebsite.com/homepage.htm. I just want it to receive the focus.

Again, I apologize of this issue has been (repeatedly ?) addressed in these forums. As I say, I did a cursory search and came up empty.

Regards,

Chris Colby

By TheFoz anchor Thursday, 24. April 2008, 11:04:38

avatarI have a similar problem with the window.open() method.

I have a number of links to other web-sites. Generally I load these into the same named window, when they contain similar subject matter, using a link with href and target attributes (this works fine).

I also use an onclick attribute to call a javascript function to focus (after a delay) the window containing the off-site link, using window,focus() (which generally doesn't work if the browser is configured to oen new windows in a new tab, but that is another problem). In this function I am using window.open() with a blank URL to get the window object before attempting to give that window the focus. In Opera only, this always opens a new blank window (in addition to the window that I want).

Maybe there is a different recommended way to do this in Opera. I would like to know.

Moderators: jax | malware | mcx | operadev