• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Find links with javascript

toughwimp11

Senior member
I recently started scripting with greasemonkey and JS. i'm trying to make a script that will find if a link exists on the page (that executes some javascript). I want to check if that link exists and if it does, it automatically executes it.

any ideas on how to do this?
 
Code:
function recursiveCheck(element)
{
for (var t=0;t<element.ChildNodes.length;t++)
{
checkIsAnchor(element.ChildNodes[t]);
recursiveCheck(element.ChildNodes[t]);
}
}

function checkIsAnchor(element)
{
if (element.nodeName.toUpperCase() == "A")
{
if (element.HREF.toUpperCase() = "MYTARGET")
{
DoSomethingWithAnchor(element);
}

}
}



recursiveCheck(document.Body);
 
Back
Top