Javascript redirect

Discussion in 'Javascript' started by thomas.humberset@gmail.com, Aug 11, 2006.

  1. Guest

    Hello!

    Could someone please help me on the following case.
    I have a page that opens a popup/child-window (window.open(...)). This
    childwindow redirects the mainwindow and closes itself if everything is
    ok.
    BUT, the problem is when a user closes the childwindow using the x
    before redirect has activatet from the childwindow. Then the mainwindow
    is stuck on the waiting page.
    However, I get the mainwindow to check if child is closed using
    onfocus, and then redirect to a error page, but this even fires if the
    childwindow redirects ok and closes. (Because of the onfocus event).
    So the problem is that it will always redirect to the same page
    (errorpage) and not take any notice of the redirect from the
    childwindow.

    So is there a way for me to check if the page is allready being
    redirected or that the childwindow just closed with no redirect?

    Thanks!

    /Mr. T
    , Aug 11, 2006
    #1
    1. Advertising

  2. marss Guest

    напиÑав:

    > However, I get the mainwindow to check if child is closed using
    > onfocus,


    Use standard property window.closed to test window state instead of
    window.focus()

    > and then redirect to a error page, but this even fires if the
    > childwindow redirects ok and closes.


    Redirect main window before closing child window and then close child
    window.

    E.g.


    child.htm

    <html>
    <head>
    </head>
    <body>
    <span
    onclick="opener.location='ProperPage.htm';window.close();">Redirect to
    Proper Page</span>
    </body>
    </html>



    main.htm

    <html>
    <head>
    <script>
    var w;
    function OpenChild()
    {
    w = window.open("childPopup.htm");
    setInterval("CheckChild()", 1000);
    }
    function CheckChild()
    {
    if (w.closed)
    document.location = "ErrorPage.htm";
    }
    </script>
    </head>
    <body>
    <span onclick="OpenChild()">open child</span>
    </body>
    </html>
    marss, Aug 11, 2006
    #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. dh
    Replies:
    2
    Views:
    520
  2. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,206
    Srowe1975
    Oct 15, 2008
  3. Replies:
    7
    Views:
    12,961
    justingrant
    Oct 18, 2008
  4. Sal
    Replies:
    1
    Views:
    362
  5. Ron Howard
    Replies:
    2
    Views:
    500
    Ron Howard
    Aug 11, 2004
Loading...

Share This Page