Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

target=_top on redirect

Posted on 2000-03-13
11
Medium Priority
?
397 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 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

722 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