Force a document to load at the top level

J

janders

Hey all,

I've got a document that I want to ensure always get loaded into the
top level document and not into a frame or iframe. I've got it figured
out how to detect if the document is loaded into a frame. But what I
want to happen is the HTML content in the iframe to be displayed in the
top level document w/o a return trip to the server.

Here's what I'm thinking:

function forceTopLevelDocument() {
if (top != self) {
//load the HTML from child document into parent document
//without a return trip back to the server
}
}

What I can't figure out is how to take the document loaded into a child
frame and push it's contents up into a parent frame.

Any thoughts? Thanks in advance!!

Jason
 
R

Randy Webb

janders said the following on 5/26/2006 6:20 PM:
Hey all,

I've got a document that I want to ensure always get loaded into the
top level document and not into a frame or iframe. I've got it figured
out how to detect if the document is loaded into a frame. But what I
want to happen is the HTML content in the iframe to be displayed in the
top level document w/o a return trip to the server.

Here's what I'm thinking:

function forceTopLevelDocument() {
if (top != self) {
//load the HTML from child document into parent document
//without a return trip back to the server
}
}

What I can't figure out is how to take the document loaded into a child
frame and push it's contents up into a parent frame.

Any thoughts? Thanks in advance!!

What makes you think that a cached document will cause a return trip
back to the server? top.location.href = this.location.href in an
appropriate place.
 
J

janders

Hey Randy, thanks for the reply. The document is a dynamic JSP that
can't be allowed to be cached. I've got the http headers set to not
allow caching so unfortunately, it will always result in another round
trip to the server. And since much of the data that generates the page
is request-scoped, the second time the page gets rendered, it will
likely come back incorrect.
 
R

Randy Webb

janders said the following on 5/30/2006 12:15 PM:
Hey Randy, thanks for the reply.

Hi, thanks for quoting what you are replying to next time.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

The document is a dynamic JSP that can't be allowed to be cached.

<nitpick>
You can't prevent my browser from caching it, you can only suggest that
it doesn't
I've got the http headers set to not allow caching so unfortunately,

And you hope the UA honors those headers and doesn't cache it.....
it will always result in another round trip to the server.

The page is already in the cache, let it be unframed. You are attempting
to solve the wrong problem.
And since much of the data that generates the page is request-scoped,
the second time the page gets rendered, it will likely come back incorrect.

If it is wrong the second time, it was wrong the first time.
 
J

janders

With all due respect, I'm not really looking to be told what problem I
should be solving. Just wanting to know if it's possible to take the
HTML content from an iframe and load into the top level document w/o a
return trip to the server. If it can't be done, that's all I need to
know.

Thanks!

Jason
 
R

Randy Webb

janders said the following on 5/30/2006 6:15 PM:
With all due respect,

And with the respect due back to you, please quote what you are whining
about in the future.
I'm not really looking to be told what problem I should be solving.

This is Usenet, not your help desk. You ask a question, it gets
discussed. Don't like the conversation? You move on.
Just wanting to know if it's possible to take the HTML content from
an iframe and load into the top level document w/o a return trip to
the server.

Yes, it can be done if both documents are from the same domain.
If it can't be done, that's all I need to know.

That's not all you need to know, you also need to know how to do it
since it can be done.
 
J

janders

OK, it appears that Randy would rather not play nice. Is there anyone
else out there that knows the answer?

I'm just trying to move HTML from an iframe to the top level document
w/o having to make a round trip to the server.

Anyone? Thanks in advance!

Jason
 
L

Lasse Reichstein Nielsen

janders said:
I'm just trying to move HTML from an iframe to the top level document
w/o having to make a round trip to the server.

Just changing the location of the top window should suffice. If the
page has been loaded, it's most likely also cached by the browser,
so you won't have a server roundtrip (unless the server requests that
it's not cached, obviously).
You'll still have a reload, but it's from local disk, so it should
be fast.

/L
 
J

janders

A thousand thanks for your helpful comment, Tony. Does this mean you
also have a contribution to the original javascript query?
 
J

janders

Hey Lasse, thanks for the reply. I've set the headers to instruct the
browser to not cache the document and since the document is constructed
from request scoped objects, a second request wouldn't be rendered
correctly.

So I'm hoping I can use JS to push the contents of the iframe into the
top level document w/o resetting the top window's location. Do you know
if this is possible?
 
R

Randy Webb

janders said the following on 6/2/2006 12:41 AM:
Hey Lasse, thanks for the reply.

At least you are quoting now. Now, if you can just refrain from top-posting.
I've set the headers to instruct the browser to not cache the document
and since the document is constructed from request scoped objects, a
second request wouldn't be rendered correctly.

And you hope the users settings allow the browser to honor that request.
Cache Headers are a request, not a demand.
So I'm hoping I can use JS to push the contents of the iframe into the
top level document w/o resetting the top window's location. Do you know
if this is possible?

I have already told you, yes, it is possible.

Hint:
Read the innerHTML of the framed page, write it to the parent page.

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
J

janders

Funny, I had a different answer to that question. Ya learn something
knew every day.

:)
 
R

Randy Webb

janders said the following on 6/2/2006 1:44 AM:
Funny, I had a different answer to that question. Ya learn something
knew every day.

Yeah, but you still haven't learned how to take the contents of an
IFrame and place it in the top document (or any other document for that
matter) without retrieving it from the server again. It is quite simple
actually, you just have to figure out how to get someone to tell you how
to do it.

Hint: Annoying the people who can answer you is not the best way to get
an answer.
 
J

janders

Randy, I'm not gonna suck your d*** so for god's sakes, quit asking.
Geesh, buy me dinner first and then MAYBE...
 
J

janders

Forgot to get back to this. For the curious (and the archive
searchers), here's the solution that worked for me:

function ensureIsTopLevelDocument() {
if (top != self) {
top.document.body.innerHTML = document.body.innerHTML;
}
}
 
R

Randy Webb

janders said the following on 6/14/2006:
Forgot to get back to this. For the curious (and the archive
searchers), here's the solution that worked for me:

function ensureIsTopLevelDocument() {
if (top != self) {
top.document.body.innerHTML = document.body.innerHTML;
}
}

It's nice to see you finally figured it out without anybody telling you.

Now, all you have to do is figure out what happens if I put your page
into my frameset.

Hint: Your code will run into a security issue.

Hint #2: That is for the curious and the archive searchers.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top