We help IT Professionals succeed at work.

Using Meta HTTP-EQUIV=Refresh with frames and target="_top"

Mike93110
Mike93110 used Ask the Experts™
on
I'm stuck on something that may well be easy.  I am using a refresh tag like the one below within a frame:

<META HTTP-EQUIV="Refresh" CONTENT="60; URL=HTTP://www.mysite.com">

I would like to be able to have this refresh automatically go to the top level and thereby eliminate all of the frames.  I can do this within a form statement or via a URL using target="_top" as in the example below:

<a href="HTTP://www.mysite.com" target="_top"> </i>Finished</a>

I can't seem to figure out how to properly format the target="top" within the Meta tag to work.  Is there a way to do this or some straight forward HTML equivalent?  If standard HTML can't do it, are there other simple options?

Thanks,

Mike
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Mike93110,

The META tag does not take a target.  However it sounds like you are entering this meta tag in the html for one of the frames instead of the html of the page that sets up the frames.  Put the META tag in page that sets up the frames.

If you can't do that then you can try to use the body tag and javascript below.

<body onload="top.document.location='http://www.mysite.com';">

Let me know if neither option will work.  Let me know if you have any questions or need more information.

b0lsc0tt

Author

Commented:
Hi b0lsc0tt,

Thanks.  A quick test shows that the body tag may work for us.  I'll test it out more thoroughly this morning and if the implementation solves our issue, I'll get accept your response within the next few hours.

Thanks again for the quick response and straight forward solution.

Mike

Commented:
Your welcome!  Let me know if there is an issue or if you need more info and how the test works out.

bol

Author

Commented:
bol,

That did give us the solution for which I was looking.  Let me know if you'd like me to ask either of the following as new questions.

1) We have two frames.  One has a form statement with input fields.  When the uses enters information into the input frame we'd like the second window to refresh itself.  Is there a simple way to do this by adding some code to the first window with the input field without reloading all the frames including the top frame?  If the body tag onload is the simplest option and assuming that the second window's name was Win2 what would I need to change the top.document.location to (e.g.,  Win2.document.location)?

2) Also if the Win2 frame had a scroll bar and the user had scrolled  halfway down the frame, is it possible to easily refresh their page and return them to the same scroll point.  If that is possible wthout too much programming but it would be more appropriate to ask to ask that as new question, just let me know that it is possble and I'd be happy to ask it as a new question.

Thanks again,

Mike

Commented:
Your welcome!  I'm glad the test did what you wanted.

1. Are you submitting the form?  If so the quick answer is to make the second window the target.  That will cause it to be refreshed when the form is submitted.  Depending on the situation it may not work for what you have on the pages but it is the easiest way.  The form tag below is an example of how you could do it (notice the target attribute).

  <form method="post" action="filename.asp" target="frameWindowName">

2. Most browsers will return to the same portion of the page if the user clicks or initiates the refresh.  However to do it in programming you would need some way to know where they are and to put them back.  Named anchors (e.g. <a name="part2"></a>) in your html is one way to "name" sections.  A url can go to that specific section using #name (e.g. <a href="page.htm#part2">Go to part2</a>).  In Javascript you can use focus to go to a specific form field but I don't know if that would work in this case.  Is there something to "focus" on and how would you know what it is?

Both of these deserve their own new questions.  My reply to one may be enough so you don't need a question for it but the second one is more involved and we would need more details.  Even clever programming may not be able to do the second one.  Feel free to post a follow up here if you have some question about this comment.  I will keep an eye open for the new questions if you post them or you could post the URL here (if with in the next few days) to notify me.  I hope this helps!

Author

Commented:
Thanks for the help.  I'll try one and if that doesn't work I'll post a new question for it.  It sounds like two may be a bit trickier.

Commented:
> It sounds like two may be a bit trickier
Yeah, but not necessarily impossible.  It just depends on the specifics.  It can be very easy under the right circumstances.

I'm gald that I could help you.  Thank you for the grade, the points and the fun question.

bol