By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

How do I force my form to be the top frame

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mi*****@preece.net (Mike Preece) writes:
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.
<URL:http://jibbering.com/faq/#FAQ4_24>
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
mi*****@preece.net (Mike Preece) wrote in message news:<1b*************************@posting.google.c om>...
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.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.