• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

target=_top on redirect

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
gabrielf072699
Asked:
gabrielf072699
  • 8
  • 3
1 Solution
 
knightEknightCommented:
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
 
knightEknightCommented:
... use the above code in place of the meta tag
0
 
knightEknightCommented:
Or, if you don't want to pause:

<SCRIPT language='javascript'>
  top.location="new.htm";
</script>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
knightEknightCommented:
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
 
knightEknightCommented:
>> ... it will loop indefinitely ...

that is, if you put this code in new.htm
0
 
knightEknightCommented:
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
 
gabrielf072699Author Commented:
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
 
knightEknightCommented:
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
 
gabrielf072699Author Commented:
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
 
knightEknightCommented:
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
 
gabrielf072699Author Commented:
Okay, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now