How do I force my form to be the top frame

M

Mike Preece

Hi

I have to apologise for this in advance.. Sorry I know this is the
wrong group to ask but this question I don't know where I should be
asking it.

What can I send from the server to a browser that will force the HTML
form I'm sending to break any pre-existing frames? I've seen and tried
things like having a <BASE TARGET="_top"> (or "_parent") tag in the
<HEAD> but that doesn't seem to work. I know that having a link on the
browser with javascript:top.location.href="... works. Maybe this is
the right place to ask after all... is there something I can do in
conjunction with an OnLoad event?

Regards
Mike.
 
L

Lasse Reichstein Nielsen

What can I send from the server to a browser that will force the HTML
form I'm sending to break any pre-existing frames?

Let me get this straght:
You are sending an HTML page containing a form.
You want that page to "break out of frames".

The typical way to do that is to add the script:
<script type="text/javascript">
if (window != top) {
top.location.href = location.href;
}
</script>
Put it as early in the head section as reasonable.

This should work, even if the other frame lives in another domain. You
can set the location.href, but not read it.
I've seen and tried things like having a <BASE TARGET="_top"> (or
"_parent") tag in the <HEAD> but that doesn't seem to work.

That works for the *next* page you load, either by following a link
or submitting a form.
I know that having a link on the browser with
javascript:top.location.href="... works.

Maybe, but it's bad style anyway. At least use the onclick event
handler.
is there something I can do in conjunction with an OnLoad event?

That would be long to wait. If you are going to redirect people (which
will make the page load again in the new location), do it as soon as
possible.

/L
 
M

Mike Preece

Hi

I have to apologise for this in advance.. Sorry I know this is the
wrong group to ask but this question I don't know where I should be
asking it.

What can I send from the server to a browser that will force the HTML
form I'm sending to break any pre-existing frames? I've seen and tried
things like having a <BASE TARGET="_top"> (or "_parent") tag in the
<HEAD> but that doesn't seem to work. I know that having a link on the
browser with javascript:top.location.href="... works. Maybe this is
the right place to ask after all... is there something I can do in
conjunction with an OnLoad event?

Regards
Mike.

I should probably add that there are really two requirements. When
people first go to my site they'll get a selection screen with no
frameset involved. Then, when they've made a selection, I want a
frameset to appear with the usual navigation and main frame. If they
then decide to return to the selection screen (or if the application
times out) I want to break the frameset and show the selection screen
without frames again. Also - there has to be the option to refresh the
frameset at any time - initiated from the server. This is because the
contents of both the navigation and main frame can be changed from
within the application (running on the server). I can't seem to stop
my frameset appearing within the main frames.

Regards
Mike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,100
Messages
2,570,635
Members
47,243
Latest member
RustyPalin

Latest Threads

Top