my dog learned polymorphism
The moose likes HTML, CSS and JavaScript and the fly likes window.opener not working for FIREFOX. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "window.opener not working for FIREFOX." Watch "window.opener not working for FIREFOX." New topic

window.opener not working for FIREFOX.

mohammed zubedi

Joined: Jun 04, 2008
Posts: 9
Dear Members
I need very urgent help on the following code.
I have a login form which calls the "adminLog(obj)" function and logged the user and where as window.opener will contact the object for";....")
and I have another onload method called "Set_focus()" on refreshing the page it will check for window.opener is null or not and if its not null then it will close the associtate window. Follow the code below please.

function adminLog(obj)
var loginid = encode64(obj.loginidAdmin.value);
var pswd = encode64(obj.passwdAdmin.value);


window.opener ="UserAdminPage.jsp?loginid="+loginid+"&passwd="+pswd);

function set_focus()

if(window.opener != null)


Above code works perfect for IE but doesn't work for Firefox, can any one help me on this, I want to close the window which gets open by, when ever user refresh the parent window, and this work fine in IE but its not working in Firefox. ANY HELP IS HIGHLY APPREICATED.

Thanks in advance.
Mohammed Zubedi
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Are you getting any error messages in the "Tools -> Error Console" window?
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You can not close a window that you did not open with JavaScript. So you should not be able to close the parent window. I am not sure why IE is alowing you to do that. [What version are you using? IE6 sp1?]

mohammed zubedi

Joined: Jun 04, 2008
Posts: 9
IE Version is 7. (IE7).
I'm not getting any error messages at all.
is there any possible way to make this code work with firefox as well?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10824

I had the same problem a few days back (I am not a javascript guy!)
My requirement was to close the window when the user clicks on an image.
Just like you I figured out that if the window is not opened by a script, it cannot be closed. Fortunately (for me) the client is using IE and I dropped the matter.

However, during my extensive googling, I came accross some post which said it was because of this line

(Unfortunately I cannot recall the article link)

One of the possible solutions could be setting this to true, but then I dont know what else might be affected. Like I said, I am not a javascript guy.

PS. The above line is from the <MOZILLA_HOME>/greprefs/all.js. I have FF

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
mohammed zubedi

Joined: Jun 04, 2008
Posts: 9
Thanks Maneesh Godbole, I tried those options earlier but still its' not working, moreover I'm working on our own product which has to be compatible on both Firefox and IE, but its not working on FF, is there any any any ways where I can make it done, I have been trying this for past one week and no results .

Anyways, Thanks for your suggestions.

subject: window.opener not working for FIREFOX.
It's not a secret anymore!