wood burning stoves 2.0*
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
Author

window.opener not working for FIREFOX.

mohammed zubedi
Greenhorn

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 window.open(";....")
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);

obj.reset();

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

function set_focus()
{

if(window.opener != null)
{
window.opener.close();
}
else
{}

document.forms[0].reset();
document.forms[0].elements[0].focus();
}

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 window.open, 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
mohammed.zubedi@xius-bcgi.com
Ulf Dittmer
Marshal

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


Ping & DNS - my free Android networking tools app
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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?]

Eric
mohammed zubedi
Greenhorn

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: 10451
    
    8

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 2.0.0.16


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

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.

Mohammed.
 
jQuery in Action, 2nd edition
 
subject: window.opener not working for FIREFOX.