Solved

target=_top on redirect

Posted on 2000-03-13
11
395 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
[X]
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
  • 8
  • 3
11 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 50 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
15 puzzle in Javascript/html 2 88
JSON help 8 47
Woo-commerce gallery not working properly 12 40
Make qty change inside array as well 1 20
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

738 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