Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to close the window in Firefox 2.0

    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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You can only close windows using javascript that were originally opened with javascript.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    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
    Last edited by rnsmurthy; 12-19-2006 at 08:23 AM. Reason: for more clarification

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by rnsmurthy View Post
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •