- Author was Featured
- Bought between 10 and 49 items
- Contributed a Blog Post
- Exclusive Author
- Germany
- Has been a member for 3-4 years
- Item was Featured
- Referred between 100 and 199 users
Hey guys,
I already googled for it, but I can only find a solution how to get all internal urls of a site, but lets say the internal url refers to a .jpg and not to an internal site, how could I check that with js?
Thx
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
Didn’t test it but should work:
var allLinks = document.links, jpglinks;
for (var i=0; i<allLinks.length; i++) {
if(/\.jpg$/.test(allLinks[i].href) jpglink[] = allLinks[i].href;
}
alert(jpglinks);
- Author was Featured
- Bought between 10 and 49 items
- Contributed a Blog Post
- Exclusive Author
- Germany
- Has been a member for 3-4 years
- Item was Featured
- Referred between 100 and 199 users
Yes for images, but it was only an example. I mean any other file extensions too, so in other words, give me all internal links that refers to an internal site and not to a file, like jpg, mp3, zip, pdf etc.
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
var allLinks = document.links, inlinelinks;
for (var i=0; i<allLinks.length; i++) {
if(/\/$/.test(allLinks[i].href) inlinelinks[] = allLinks[i].href;
}
alert(inlinelinks);
but I guess you have others as well. I think the only way is to blacklist extensions:
var allLinks = document.links, files;
for (var i=0; i<allLinks.length; i++) {
if(/\.(jpg|gif|png|mp3|zip|pdf)$/.test(allLinks[i].href) files[] = allLinks[i].href;
}
alert(files);- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
var url = document.URL;
var base = url.substring(0, url.lastIndexOf("/"));
var a = /http/;
var b = new RegExp(base);
var i = links.length; // "links" array already populated
while(i--) {
if(links[i].match(b)) {
console.log("link is internal");
}
else if(links[i].match(a)) {
console.log("links is external");
}
else {
console.log("link is internal");
}
}
@CJ
thats nice , good work.
