View Full Version : Maybe a simple fix?

03-15-2012, 02:25 AM

Im trying to make an imacro/javascript script that checks a webpage for names, and if either of the names are found, i want the script to alert me, if not, continue looping/reloading the page.

Im not at all good with javascript, imacro is more sort of my thing, however what i do have, doesnt seem to do anything.

var links = document.getElementsByTagName('a');
for (var i in links){
if (links[i].value == "Simon" || links[i].value == "James"){

i dont know if its something simple i'm missing, or whether im nowhere near, but ive spent all day trying to do this, and lost all patience.

Any suggestion/fixes?

03-15-2012, 02:41 AM
Here is something to consider ...

<a href=# >johnny</a>
<a href=# >ralph</a>
<a href=# >sue</a>
<a href=# >James</a>
var links = document.getElementsByTagName('a');
for (var i = links.length;i--;){
if (links[i].innerHTML == "Simon" || links[i].innerHTML == "James"){

03-15-2012, 02:45 AM
I doubt putting javascript outside of the <body> element is valid. It should be in the <head> or <body>

03-15-2012, 02:57 AM
Meh, it doesnt work. And clearly i dont know what im doing.

WebDev, im using the javascript in iMacros firefox plugin, which doesnt need any body etc.

Infact, using the first code Davey gave me, it errored and wouldnt run because of ''SyntaxError: invalid XML attribute value (Error code: 991)''

I dont know what else to try.

03-15-2012, 02:57 AM
And thank you both for the speedy replies.