Redirecting the parent window on the close of the child.

Posted on 2002-05-22
Medium Priority
Last Modified: 2008-02-26
Trying to 'elimanate' the back button on an asp/javascript data collection site we have opened a child window with all the necessary toolbars disabled using window.open(...).  When certian events happen I would like to close the child window and redirect the parent window.  The certian events and the desired parent actions are as follows:

Child Action                  Parent Location
Session Timeout               Login Page
Close Window                  Main Menu page

The Session Timeout is a page with a link to the Login Page.  Right now the Session Timeout opens in the child window.  Is there a way to determine of the page is opened in the named child window?  If so how can I close this child window and redirect the parent to the Session Timeout page.  Or could I change the link on the Session timeout to just redirect the parent to the login page.

Is there a unload event for the browser?  If so what code will I need to use to redirect the parent to the main menu page.

Please answer with complete javascript functions not code snippets.

Thank you in advance,
Michael Dove
Question by:kaytrim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Expert Comment

ID: 7034831
What kind of error page is sent back to the client? IS it a normal page you supply?


Accepted Solution

kcm76 earned 1200 total points
ID: 7035034
in the child window if the session timesout u want to close the child window and open the login page in the parent window. in that case.write the following code in the child window.
// this will open the login.asp in the parent window
window.opener.location.href = "login.asp";

// close the child window.

similarly u write the same in the onunload event.
window.opener.location.href = "mainpage.asp";

btw, what do u mean by
Child Action...........Parent Location?


Author Comment

ID: 7037040

Thanks for the code this I will try it out and let you know.  

The Child Action is what happens on the child window.  The Parent Location is where I want the parent window to redirect to.

Thanks again,

Author Comment

ID: 7037415
Thanks KCM, just what I needed to get the job done.

Michael Dove

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question