I want to achieve the already working "if-solution-result" of this:
window.onload = function(){
if(document.body.innerHTML.toString().indexOf('jeff') > -1){
alert('marker1 gefunden');
}
if(document.body.innerHTML.toString().indexOf('lisa') > -1){
alert('marker2 gefunden');
}
// it could go on and on from here...
};
in a more elegant way with a "for..." loop, but i didn't get it working.
var marker = ["paul", "maria", "jeff", "lisa"];
for (var i=0; i<marker.length; i++){
if(document.body.innerHTML(marker) > -1){
alert((marker) + 'gefunden');
}
}
I'm stuck on the basics on how to manage information inside of loops.
What this should do in the end (as my "if" coding shows):
Load HTML >> Check if one or more of the Arrays are found >> Open an alertbox with what is found.
document.body.innerHTML.indexOf(marker[i]), btw, you don't needtoString()because the attributeinnerHTMLreturns a String.