I have a webpage where there is a textarea within an iframe. I need to read the value of this textarea from its child page using JavaScript.
Presently by using window.parent.getelementbyID().value
in the JavaScript, I am able to fetch values of all controls in the parent page except the textarea within the iframe.
Can anyone please give me any pointers to resolve this issue?
window.frames['myIFrame'].document.getElementById('myIFrameElemId')
not working for me but I found another solution. Use:
I checked it on Firefox and Chrome.
this code worked for me:
Two ways
OR
If your iframe is in the same domain as your parent page you can access the elements using
document.frames
collection.If your iframe is not in the same domain the browser should prevent such access for security reasons.
You should access frames from
window
and notdocument
Make sure your iframe is already loaded. Old but reliable way without jQuery: