Window.Close() not working on Firefox

Last post 05-22-2008 6:16 AM by blodfox777. 6 replies.

Sort Posts:

  • Window.Close() not working on Firefox

    05-21-2008, 4:18 PM
    • Member
      269 point Member
    • diadem_2k
    • Member since 12-11-2006, 6:04 PM
    • Posts 313

    I have a case where if users clicks logout link, he will be directed to logout.aspx page and in the page_load of logout.aspx page.....i have added this code:

    This below pasted code works fine on IE6 and IE7 but not in firefox....i did search on google and tried all the ways that i found like adding:

    // Scripts & Windows prefs
    pref("dom.allow_scripts_to_close_windows", true);

    but nothing seams to be working for firefox??? is there any work around to fix this issue so that it works on IE and Firefox as well????

    thanks a lot in advance............ 

    ==================================================================================

     // Build A JavaScript String That Will Close This Web Browser Window
            StringBuilder jsScript = new StringBuilder();
            jsScript.Append("<script language='javascript' type='text/javascript'>");
            jsScript.Append("window.close();");
            jsScript.Append("</script>");

            //Add The JavaScript To The HTML Stream
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "CloseBrowser", jsScript.ToString());

     ==================================================================================

  • Re: Window.Close() not working on Firefox

    05-21-2008, 5:12 PM
    • Contributor
      2,594 point Contributor
    • joshj
    • Member since 05-17-2007, 9:37 PM
    • Posts 431

    From the mozilla developer's site:

    This method (window.close) is only allowed to be called for windows that were opened by a script using the window.open method...

    http://developer.mozilla.org/en/docs/DOM:window.close

     


    Hypercasting™ - Turning the internet into a retail tool. www.muddhypercasting.com
  • Re: Window.Close() not working on Firefox

    05-21-2008, 11:40 PM
    Answer
    • Participant
      1,092 point Participant
    • blodfox777
    • Member since 07-12-2007, 8:30 AM
    • Posts 159

    Hi

    use the following code instead of "window.close();"

    function winClose(){ window.top.opener = null; window.close(); }

    or

    function   closeWindow()   {    window.open('','_parent','');   window.close(); }

    if it doesn't works

    please set your firefox browser:

    1.input "about:config " to your firefox address bar and enter;

    2.make sure your "dom.allow_scripts_to_close_windows" is true

    Hope this helps!

    Regards!

    -- "Mark As Answer" If my reply helped you --
  • Re: Window.Close() not working on Firefox

    05-22-2008, 1:42 AM
    • Participant
      1,250 point Participant
    • jagan.unique
    • Member since 02-08-2008, 9:42 AM
    • Hyderabad, India
    • Posts 237

    Hi

    try this. its working on both IE and FF

    <head runat="server">
        <title>Untitled Page</title>
      <script language="javascript">
     
       function openwin (url) {
           newwindow = window.open( url ,'openwin')
        }

       </script>

    </head>
    <body>
    <form runat="server" id="form1">
    <a href="javascript:openwin('default.aspx')">new window</a><br/>

        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="window.newwindow.close();" />
    </form>
    </body>
    </html>

     

    Click “Mark as Answer” on the post(s) that helped you.
  • Re: Window.Close() not working on Firefox

    05-22-2008, 5:40 AM
    • Member
      269 point Member
    • diadem_2k
    • Member since 12-11-2006, 6:04 PM
    • Posts 313

     blodfox777,

    i tried the solution which you have posted but it didn't work....when i set the browser settings to true (dom..allow etc... to true)

    then it worked but wondering how to let users know about this....it would be nice if we have server side solution.......

    jagan...i will try your method and get back to you.... 

     

  • Re: Window.Close() not working on Firefox

    05-22-2008, 6:08 AM
    • Member
      696 point Member
    • feroze1
    • Member since 03-30-2007, 9:42 AM
    • Lahore
    • Posts 186
    use tihs 
    <a href="javascript:window.close();">Close This Window</a>
    Please "Mark As Answer" if helpfull..
    Feroze Ahmed
  • Re: Window.Close() not working on Firefox

    05-22-2008, 6:16 AM
    • Participant
      1,092 point Participant
    • blodfox777
    • Member since 07-12-2007, 8:30 AM
    • Posts 159

    feroze1:
    use tihs 
    <a href="javascript:window.close();">Close This Window</a>

    I'm sorry but it can not be done if the window was not open by "window.open()" function

     

    Regards!

    -- "Mark As Answer" If my reply helped you --
Page 1 of 1 (7 items)