Accessing id from iframe
2 answers
You have to be careful if you are accessing the iframe script from your parent page to ensure that your iframe has finished loading before requesting it. Here's an example:
window.onload = function () {
document.getElementById('iframeId').onload = function () { //Attach an onload function to the iframe
//Do the stuff you want to do with the iframe here
//because this function is executed once the iframe has finished loading
};
};
+1
source to share
This is a small example I followed,
<title>Untitled Page</title>
<script type="text/javascript" >
function ShowVal() {
alert(myIframe.document.getElementById('nameText').value);
}
</script>
'myIfrmae' is the id of the iframe. and 'nameText' is the textbox control on the page contained in the iframe.
I was calling this ShowVal function from the parent page with a single button click.
Thank.
PS Sorry, failed to post the whole example. Having problems publishing Html.
0
source to share