...

View Full Version : parse href attribute?



Adee
08-28-2010, 11:15 AM
Right, so there are a bunch of links in this format:
<a href="/profiles/########">username</a>

I'm using greasemonkey, and what I want to do is go through and get all of the /profiles/######## part of the anchor tag. I'm using Regex and I can't seem to get a match.

This is what I have so far:


function ok() {
var names = document.getElementsByTagName('a');
var reg = new RegExp("WHAT GOES HERE?");
var e = "links:\n";

var i = 0;

while(i<10) {
e += reg.exec(names[i].href) + "\n";
i++;
}


alert(e);
}

ok();


what is actually desired is I want there to be a way I can select these somehow as well..

Adee
08-28-2010, 11:33 AM
K so I've figured out my problem.. I needed to use getElementsByClassName.. now that I have the numbers, I still need to figure out a way to get them out of the document. I'd rather not make a giant 200 line alert window, is there another easier way? Also, how do I filter out the null results?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum