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?

How to get links from 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.

  • to take HTML pages and regular expressions parse? - alexsuslin
  • Chrome browser does not support forEach ! - user190197

2 answers 2

 var frames = document.getElementsByTagName("iframe"), links = document.getElementsByTagName("a"); frames.forEach(function (frame) { var frameLinks = frame.contentDocument.getElementsByTagName('a') || []; links = links.concat(frameLinks); }); 

    From an iframe from another domain will not work - security policy.

    • Ie chrome sees this link and chromium expansion can not? so do you get it? - jonior