Quote:
Originally Posted by Airblader
Which indicates that you get an error, for example something is undefined. Use the console to verify what happens.
|
Right, I got that there was an error, but I'm literally running the code above. Besides the conditions and the "alert" calls, I'm actually doing nothing (everything else is commented out), and the behavior is the same. When the condition is met, everything runs, else nothing is run. So my question is more: is there any reason why that first condition being false should mean that the rest of the code doesn't run?
Here, for reference, I am running this *exact* code (this is the entire script):
Code:
var msg = document.body.innerHTML;
if(msg.match(/Big monster/gi).length > 0)
{
alert("attack");
//Do stuff
}
else
{
alert("not attack");
//Do other stuff
}
And the behavior is as I said above. Either "attack" gets displayed, or nothing does.