...

View Full Version : How to close the window in Firefox 2.0



rnsmurthy
12-19-2006, 09:08 AM
How to close the window in Firefox 2.0 without changing this value (dom.allow_scripts_to_close_windows, true)(as true) .
We can able to close the window by using the javascript : window.close(); if we change the pref(dom.allow_scripts_to_close_windows, true) (as true);

Please let me know the javascript code for closing the window without doing the changes in below given Mozilla js.
(C:\Program Files\Mozilla Firefox\greprefs\all.js).

Thanks, Murthy

_Aerospace_Eng_
12-19-2006, 09:09 AM
You can only close windows using javascript that were originally opened with javascript.

rnsmurthy
12-19-2006, 09:20 AM
You can only close windows using javascript that were originally opened with javascript.

Thanks Aerospace. But I am not opening the window through javascript which I need to close the window.
So, is there any other option?

The below javascript coding is working fine in Firefox1.5.0.4 (without doing the changes in pref(dom.allow_scripts_to_close_windows, true) (as true))

top.window.opener = top;
top.window.open('','_parent','');
top.window.close();

this code is able to close the window(which is not opened through javascript) in firefox1.5.0.4 but not in firefox2.0

Thanks, Murthy

_Aerospace_Eng_
12-19-2006, 09:32 AM
I'm surprised it worked in Firefox at all. For security reasons this was likely fixed. So no there is no other option. Why are you wanting to close the parent window anyways? What you are doing now is the noob thing to do. Leave the parent window alone. If the user wants it closed they will close it. Don't try to close it for them. Just move on with your little project.

liorean
12-19-2006, 01:07 PM
Thanks Aerospace. But I am not opening the window through javascript which I need to close the window.
So, is there any other option?Murthy:
Mozilla (and the other browser makers including Microsoft) have all agreed that allowing JavaScript to close browser windows in the first place was a mistake, and that it should NOT be allowed. Or at least, not be allowed without asking the user for permissions first. The reason for this is that closing windows can lead to data loss, in the form of data in form fields, in browser history, in open tabs etc.

So, live with it. When the browser makers say something was a mistake, they mean it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum