Skip to content

Instantly share code, notes, and snippets.

@jakzale
Created November 2, 2016 17:58
Show Gist options
  • Save jakzale/aff5e62b5119f8ce6d0fcabd943b374e to your computer and use it in GitHub Desktop.
Save jakzale/aff5e62b5119f8ce6d0fcabd943b374e to your computer and use it in GitHub Desktop.
List All links on a web page
(function (){
var aTags = document.getElementsByTagName("a");
var aTagsArray = [].slice.call(aTags);
aTagsArray.map(function (a) {
var result = "#";
if (a.getAttribute) {
result = a.getAttribute("href") || result;
}
return result;
}).filter(function (link) {
return link.startsWith("http");
}).forEach(function (link) {
console.log(link);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment