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
Solved

target=_top on redirect

Posted on 2000-03-13
11
392 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 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide cell in a table 2 27
alert(innerHTML); 8 32
Html fieldset fix its height and width 4 32
Binding a Grid in Javascript 5 44
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

828 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