0
Hello I am trying to run this code so that it captures all the links of a page, it works all ok, the problem is that I want to find links that contain a certain word using index but is giving the following error in the log..
Uncaught TypeError: str.IndexOf is not a function
at pesq (<anonymous>:22:14)
at <anonymous>:8:1
Some way to resolve this so that you only find the links indicated by index ?
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');
}