We help IT Professionals succeed at work.

target=_top on redirect

gabrielf072699
on
449 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">
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
... use the above code in place of the meta tag
CERTIFIED EXPERT

Commented:
Or, if you don't want to pause:

<SCRIPT language='javascript'>
  top.location="new.htm";
</script>
CERTIFIED EXPERT

Commented:
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?  
CERTIFIED EXPERT

Commented:
>> ... it will loop indefinitely ...

that is, if you put this code in new.htm
CERTIFIED EXPERT

Commented:
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>

Author

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?
CERTIFIED EXPERT

Commented:
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>

Author

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?
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
Okay, thanks.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.