I have the following HTML
<iframe id ="myIframe">
#document
<head>...</head>
<body>Text I want to get is here</body>
</iframe>
I only know the iframe's id. Using JavaScript, how can I extract the text from the body?
Assuming your iframe is in the same domain as your HTML:
var myIFrame = document.getElementById("myIframe");
var content = myIFrame.contentWindow.document.body.innerHTML;
Otherwise you'll face some Same Origin Policy issues.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.