how to load page content from iframe to the main page

H

hgl1976

Hi!

I have a web page that from a query that loads the search result into
an iframe on the page. In the search result inside the iframe i would
like to be able to load content into div tag that is in the main page.
Is that possible?



The code i have tried goes like much like this
....
function showObj(theid){

document.getElementById('externalDiv').innerHTML=document.getElementById(theid).innerHTML;

}

....
<div id="externalDiv">
//here is where i would load content from javascript
</div>

....
<iframe>
html for the object desription
.... onClick="showObj('objectdescription1')>
</iframe

<div id="objectdescription1">thedesription for nr1</div>
<div id="objectdescription2">thedesription for nr2</div>
<div id="objectdescription3">thedesription for nr3</div>

/Henrik
 
A

ASM

(e-mail address removed) a écrit :
I have a web page that from a query that loads the search result into
an iframe on the page. In the search result inside the iframe i would
like to be able to load content into div tag that is in the main page.
Is that possible?

The code i have tried goes like much like this

function showObj(theid){
var mother = parent.document.getElementById('externalDiv');
var daughter = parent.myIframe.document.getElementById(theid);
if(mother && daughter)
mother.innerHTML = daughter.innerHTML;
else
alert('something wrong !\nprobably in iframe');
}

this function can be called from main page or iframes's page.
<div id="externalDiv">
//here is where i would load content from javascript
</div>

<p><a href="javascript:showObj('objectdescription1')">
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top