Copy IFRAME content into DIV

  • Thread starter Floris van den Berg
  • Start date
F

Floris van den Berg

This has probably already asked a million times before but here goes again.
For the past hours i've been trying to copy the contents of an invisible
IFRAME to a DIV. Browsed the web a lot for examples, turns out in theory
it's pretty easy. This is what i did:

[source]

<script language="javascript">
var timer1 = "";
var done = false;

function StartWorking(){
timer1 = window.setInterval("ImWorking()", 100);
}

function ImWorking(){
if (done == true) {
window.clearInterval(timer1);
timer1 = "";
x = document.getElementById("content");
y = document.getElementById("buffer").document.body;
x.innerHTML = y.innerHTML;
}
}
</script>

<div id="content">Old content</div>
<iframe id="buffer"
src="https://secure.postplaza.nl/NASApp/tracktrace/FindByBarcodeServlet?BARC
ODE=3SPSCL50396456&ZIPCODE=3581HJ style="display:none"></iframe>

<script language="javascript">
StartWorking()
</script>

<script>
done = true
</script>

[/source]

Needless to say it doesn't work. Instead of the contents of the iframe it
shows the content of the parent document. I tried to use
ContentWindow.document.body instead of document.body, and then it doesn't
show anything at all. Anyone knows what i might be doing wrong? Thanks for
the assistance.

Floris
 
W

Whitecrest

This has probably already asked a million times before but here goes again.
For the past hours i've been trying to copy the contents of an invisible
IFRAME to a DIV...
x = document.getElementById("content");
y = document.getElementById("buffer").document.body;
x.innerHTML = y.innerHTML;

try document.frames["buffer"].document.body.innerhtml

Or a variation on that.
 
F

Floris van den Berg

Whitecrest said:
This has probably already asked a million times before but here goes again.
For the past hours i've been trying to copy the contents of an invisible
IFRAME to a DIV...
x = document.getElementById("content");
y = document.getElementById("buffer").document.body;
x.innerHTML = y.innerHTML;

try document.frames["buffer"].document.body.innerhtml

Or a variation on that.

Nope. Doesn't work. Tried window.frames["buffer"] too. No avail. Any other
ideas?

Floris
 
W

Whitecrest

Nope. Doesn't work. Tried window.frames["buffer"] too. No avail. Any other
ideas?

Go to the site in my I load a web page into a <div> that web page can be
an ASP page, hard coded what ever you want. I believe with playing it
may achieve the effect you are looking for.
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top