Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

target=_top on redirect

Posted on 2000-03-13
11
Medium Priority
?
398 Views
Last Modified: 2011-09-20
I'm trying to redirect a page to another page, but I want it to go to the top, so the frames are reset.  I tried adding 'target=_top' to a meta refresh, but that didn't work.  Is there a way in javascript?

<META HTTP-EQUIV=REFRESH CONTENT="0; URL=new.htm target=_top">
0
Comment
Question by:gabrielf072699
  • 8
  • 3
11 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 200 total points
ID: 2613480
Here is a javascript solution:

<SCRIPT language='javascript'>
  setTimeout( 'top.location="new.htm";' , 5000 );  // wait 5000 milliseconds (adjust this number to suite your needs)
</script>

_______________________________________________________________________________________________
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613484
... use the above code in place of the meta tag
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613486
Or, if you don't want to pause:

<SCRIPT language='javascript'>
  top.location="new.htm";
</script>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:knightEknight
ID: 2613505
BTW this is just an example of the syntax.  Obviously if you put this exact code in your page, it will loop indefinitely.  What exactly are you trying to do?  
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613511
>> ... it will loop indefinitely ...

that is, if you put this code in new.htm
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613517
also, you should put this in the body of the documnet in case the browser is not js enabled:

<A href="new.htm">Click Here</a>
0
 

Author Comment

by:gabrielf072699
ID: 2613544
It works, but the only problem is that when I click 'Back', it won't go back to the previous screen.  What could be causing this?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613577
Actually, the back button is working properly, but the previous page is the one that contains the code above, so it is executing that code and reloading new.htm.  (This would also happen with the META tag solution).

Try this instead:

<SCRIPT language='javascript'>
  setTimeout( 'top.location.replace("new.htm");' , 5000 );  // wait 5000 milliseconds (adjust this number to suite your needs)
</script>

or:

<SCRIPT language='javascript'>
  top.location.replace("new.htm");
</script>

0
 

Author Comment

by:gabrielf072699
ID: 2613684
Well, it sort of worked, but it goes back to the first screen hit on the site, instead of the previous page.  Is there another way?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2613696
Sorry, I don't have any thing else to suggest at this point.  If I think of anything in the next few days I'll post it here.
0
 

Author Comment

by:gabrielf072699
ID: 2613780
Okay, thanks.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

916 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