Question

  Asked: Apr 23 2008   2:31 PM GMT
  Asked by: Catullus13


How to open new page in frame without being framed by old page frame


JavaScript, Web development

Our site uses a frame for navigation (not my design), and one of site owners wants to redirect users to a new page on the site if they bookmarked the old page URL, giving them a message page first that says the old page has gone away and to bookmark the new one. Message page then closes after 5 seconds and new page opens.

When I try this using self.setTimeout, the new page opens with navigation frame inside the navigation frame for the old page, which will not do.

How do I make the old page navigation frame close and open the new page with its own navigation frame?

Here is the code I'm using:

<head>

<script language="javascript">

<!-- Set timeOut to the time to wait before redirecting -->
<!-- Set newSite to the page you want to be redirected to -->

<!--

timeOut = "2000";

newSite = "http://weblibrary.vh.eng.vzwcorp.com/weblibrary/home.do?dept=NSS";

function timer() { self.setTimeout("self.location.href = newSite;",timeOut) }

//-->

</script>
</head>

<body onload="timer()">

Thanks!

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
+2
Click to Vote:
  •   2
  •  0



Do you have to open a new window and then close the old one? Or would it be enough to simply open the new frame in the top-level window of the old one? The result would be the same (new window is open, not within a frame, and the old window is closed) and you wouldn't run into any problems with popup blockers.

If that solution will work, try this:

function timer() {
self.setTimeout("self.top.location.href = newSite;",timeOut)
}


A window's .top property refers to the top-level window -- the one that contains the frame.

HTH!

That work's great! Thanks for the help!
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development.

Looking for relevant Development Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

YuvalShavit  |   Apr 23 2008  4:45PM GMT

No problem! Nice screen name, btw — though I’ve always liked Catullus 8 most, personally. :-)