I just wanna learn how to read Iframe content in onLoad event of iframe and write it's content to the main page ? Thanks..
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
If these two documents are in the same domain, you can use the window.parent.document object in the child document's onload event handler to access the parent document.
I have struggled with same this past day. It seems to matter how you access the iframe. If you use
document.getElementById()
you get an Iframe object, which has noonload
event. However, if you access throughwindow.frames[]
array, for exampleyou get a window object, which does have onload event.
(ie uses the frame id attribute , but ff uses name attribute. So use both and make the same)
You can then assign
Notice, since iframeWindow is a window object, you use window syntax to access content.
You can use this jquery function in parent page and it also supports many other function to add and remove stuffs:
In above code:
#idofElement
is the element from HTML page in iframe whose value you want to set. I Hope it helps You..