Javascript redirect

T

thomas.humberset

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
 
M

marss

(e-mail address removed) напиÑав:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top