PDA

View Full Version : how can i update span in parent document from iframe


frontline
12-25-2002, 04:56 PM
Hello
i have iframe in document , in the document i have simple <span name="testme" id="zzz"></span>
now in the iframe im trying to access the span in this way ..
function foo(){
if(window.parent)
window.parent.document.body.onload=function(){alert(window.parent.testme.id);}
}
but with no luck , so my question is how i can access elements from the iframe to the host document
thanks

Mr J
12-25-2002, 07:09 PM
You have given your span a NAME and an ID, just the ID is required

To access <span name="testme">Your Span</span>

in the parent document

try this in the Iframe

<script>

function update(){
parent.testme.innerText="This way"
}

</script>


<a href="#null" onclick="update()">Iframe</a>