Closing a window opened in a frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Garg

    #1

    Closing a window opened in a frame

    Hi,

    I am facing a problem while trying to close a window that I've opened
    in a frame.
    I am using javascript to close my current popup window. I have written
    the following line of code on click of OK button event.

    Response.Write( "<scriptwindow. close();</script>")

    Now the problem is since this window is closed, the frame is still
    there and hence, on click of Ok button I get directed to the error
    page. I am simply clueless where my control goes when I press OK
    button. It just redirects me to the error page.

    While debugging, I tried another thing. Right below the above
    statement, I added another line of code, i.e.,

    Response.Write( "<scriptwindow. close();</script>")
    Response.Redire ct("Home.aspx" )

    Now with this code in the OK button event handler, when I clicked on
    OK button, my current aspx page clsoed and new page (i.e. Home.aspx)
    appeared in the frame.
    So, it means when I am just writing the first line of code
    ( Response.Write( "<scriptwindow. close();</script>")), at that time
    error is, perhaps, because my frame is still open and has nothing to
    display.... Dont know... :(

    How do I overcome this problem?? Please help....

    Thanks
    Shivani

  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: Closing a window opened in a frame

    Garg wrote:
    Hi,
    >
    I am facing a problem while trying to close a window that I've opened
    in a frame.
    I am using javascript to close my current popup window. I have written
    the following line of code on click of OK button event.
    >
    Response.Write( "<scriptwindow. close();</script>")
    >
    Now the problem is since this window is closed, the frame is still
    there and hence, on click of Ok button I get directed to the error
    page. I am simply clueless where my control goes when I press OK
    button. It just redirects me to the error page.
    The window object referes to the frame in this case, not the window that
    contains the frame.

    Use window.top to get the window object of the page where the frameset is:

    window.top.clos e();
    While debugging, I tried another thing. Right below the above
    statement, I added another line of code, i.e.,
    >
    Response.Write( "<scriptwindow. close();</script>")
    Response.Redire ct("Home.aspx" )
    This will remove the script tag that you written to the page, and
    instead output a redirection page to the frame. The redirection page
    will take you to Home.aspx.
    Now with this code in the OK button event handler, when I clicked on
    OK button, my current aspx page clsoed and new page (i.e. Home.aspx)
    appeared in the frame.
    No, the current page is not closed, it's just replaced by the new page.
    So, it means when I am just writing the first line of code
    ( Response.Write( "<scriptwindow. close();</script>")), at that time
    error is, perhaps, because my frame is still open and has nothing to
    display.... Dont know... :(
    >
    How do I overcome this problem?? Please help....
    >
    Thanks
    Shivani
    >

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    Working...