How to get all links from a page through Chrome extensions, including frame links?
For example on http://myip.ru
var links = document.getElementsByTagName("a"); for(var i=0, max=links.length; i<max; i++) { console.log(links[i].href); } I get links posted on the site, but not getting from the frame (browser links).
How to get links from the banner?
Update
I tried the code given in the response.
var frames = document.getElementsByTagName("iframe"), links = document.getElementsByTagName("a"); frames.forEach(function (frame) { var frameLinks = frame.contentDocument.getElementsByTagName('a') || []; links = links.concat(frameLinks); }); But an error occurs
TypeError: frames.forEach is not a function
What could be the problem?
Update 2
Collecting links like this:
var frames = document.getElementsByTagName("iframe"), links = document.getElementsByTagName("a"); frames = Array.prototype.slice.call(frames); frames.forEach(function (frame) { var frameLinks = frame.contentDocument.getElementsByTagName('a') || []; //links = links.concat(frameLinks); console.log(links); console.log(frameLinks); }); But nothing works.
