getElementsByClassName not working on parsed html data in greasemonkey

Posted by Sid on Stack Overflow See other posts from Stack Overflow or by Sid
Published on 2010-03-25T11:56:05Z Indexed on 2010/03/25 23:53 UTC
Read the original article Hit count: 327

Filed under:
|
|

Hi my code is as such

var xhReq = new XMLHttpRequest();
xhReq.open("GET", linksRaw, false);
xhReq.send(null);
var serverResponse = xhReq.responseText;
var tempDiv = document.createElement('div');
tempDiv.innerHTML = serverResponse.replace(/<script(.|\s)*?\/script>/g, '');
var plzWork = tempDiv.getElementsByClassName('organizationID').innerHTML;
console.log(plzWork);

The value of 'plzWork' :-) which is logged to the firebug console is always 'undefined' while the link code is

<a class="organisationID" href="orglists.htm">Partner Organisations</a>

I'm writing this script in the latest versions of Greasemonkey and FF 3.6

Thanks

© Stack Overflow or respective owner

Related posts about greasemonkey

Related posts about dom