Close window with frames in it

Discussion in 'Javascript' started by SledgeHammer, Jul 8, 2003.

  1. SledgeHammer

    SledgeHammer Guest

    Hi group,

    Little question that bugs me ....

    I have a page (window) with frames.
    Topframe + MainFrame = page

    I want to close the whole window, but don't know how

    Can somebody help me with this one ?

    Thx

    Berre
     
    SledgeHammer, Jul 8, 2003
    #1
    1. Advertising

  2. SledgeHammer

    DU Guest

    SledgeHammer wrote:

    > Hi group,
    >
    > Little question that bugs me ....
    >
    > I have a page (window) with frames.
    > Topframe + MainFrame = page
    >
    > I want to close the whole window, but don't know how
    >
    > Can somebody help me with this one ?
    >
    > Thx
    >
    > Berre
    >
    >


    Only a window opened via javascript can be closed with javascript.
    Assuming this multi-frame page is a requested popup, then call the
    close() method on the window object reference of that popup. E.g.:

    <script type="text/javascript">
    <!--
    var WindowObjectReferenceOfRequestedPopup ;

    function OpenRequestedPopup(strUrl, strTarget)
    {
    var windowWidth, windowHeight, windowLeft, windowTop;

    if(typeof window.screenX == "number" && typeof window.innerWidth ==
    "number")
    {
    windowWidth = window.innerWidth * .68;
    windowHeight = window.innerHeight * .68;
    windowLeft = window.screenX + window.innerWidth * .16;
    windowTop = window.screenY + window.innerHeight * .16;
    }
    else if(typeof window.screenTop == "number" && typeof
    document.documentElement.offsetHeight == "number")
    {
    windowWidth = document.documentElement.offsetWidth * .68;
    windowHeight = document.documentElement.offsetHeight * .68;
    windowLeft = window.screenLeft + document.documentElement.offsetWidth *
    ..16;
    windowTop = window.screenTop - 50;
    }
    else
    {
    windowWidth = 500;
    windowHeight = 250;
    windowLeft = 60;
    windowTop = 40;
    };

    /* The above code is just to define reasonable sizes and initial
    positions to the popup to be. */

    if (WindowObjectReferenceOfRequestedPopup == null ||
    WindowObjectReferenceOfRequestedPopup.closed)
    {
    WindowObjectReferenceOfRequestedPopup = window.open(strUrl, strTarget,
    "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth +
    ",height=" + windowHeight + ",menubar,resizable,scrollbars,status");
    }
    else
    {
    WindowObjectReferenceOfRequestedPopup.focus();
    };

    /*
    The above 9 lines of code creates the popup; if the popup is already
    opened, then it is only brought on top. This feature is possible only if
    the user allows it in Mozilla-based browsers via the setting
    Edit/Preferences.../category:Advanced/Scripts & Plugins/Allow webpages
    to:/Raise or lower windows
    */
    }

    function CloseRequestedPopup()
    {
    if(WindowObjectReferenceOfRequestedPopup != null &&
    !WindowObjectReferenceOfRequestedPopup.closed)
    {
    WindowObjectReferenceOfRequestedPopup.close();
    };
    }

    -->
    </script>

    DU
    --
    Javascript and Browser bugs:
    http://www10.brinkster.com/doctorunclear/
     
    DU, Jul 9, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    2
    Views:
    2,943
  2. Replies:
    6
    Views:
    8,843
    sateeshranga
    Aug 7, 2008
  3. Iñaki Baz Castillo
    Replies:
    7
    Views:
    874
    Iñaki Baz Castillo
    Jan 12, 2010
  4. Walter Beierdonck

    Self.close() window without the dialog close?Yes/NO

    Walter Beierdonck, Apr 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    349
    Grant Wagner
    Apr 30, 2004
  5. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    382
    Gérard Talbot
    Sep 2, 2005
Loading...

Share This Page