Hello, I am trying to execute this code so that it captures all the links on a page, everything works ok, the problem is that I want to find links that contain a certain word using indexOf error in log ..
Uncaught TypeError: str.IndexOf is not a function
at pesq (<anonymous>:22:14)
at <anonymous>:8:1
Any way to resolve this so that it only finds the particular links indicated by indexOf ?
javascript: var w = window.open('', '', 'height=300, width=300');
var a = document.getElementsByTagName('a');
var b = a.length;
if(b != 0){
w.document.write('<h1>Lista de Links </h1>');
for (i = 0; i < b; i++){
var str = a[i];
if(str.indexOf('palavra')){
w.document.write('<pre><a href=\'' + a[i] + '\'>' + a[i] + '</a>' + '</pre>');
}
}
}else{
w.document.write('Nenhum link encontrado');
}