Reputation: 131
In my parent window I have one iframe. I want to get the anchor tags present inside the iframe from the parent window. If it is possible please give the suggestion, otherwise please tell why it is not possible.
Upvotes: 0
Views: 1199
Reputation: 5256
Lets say your iframe is:
<iframe id="myframe"></iframe>
First you need to access its document
var iframe_doc = document.getElementById("myframe").contentDocument;
Now you can work with it.
To get all anchors:
var all_anchors = iframe_doc.getElementsByTagName("a");
(You will not be able to do that if the parent and the iframe don't share the same protocol, domain and port due to same origin policy)
Upvotes: 1