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

how to load page content from iframe to the main page

P: n/a
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=d ocument.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

Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ASM
hg*****@gmail.com 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')">
show description 1</a></p>
<iframe>
<iframe name="myIframe" blah >
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>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 14 '06 #2

P: n/a
Thank you!

I will try right away :)

... /Henrik

Nov 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.