How to find keywords through JavaScript and locate the scroll bar according to the location of the found keywords? I'm developing a rich text program. Now I don't know how to display the found keywords in the middle of the screen
function SearchWord(data) {
let index_all = Indexof_All(data, "a");
console.log(index_all);
}
function Indexof_All(str, v) {
let index = str.indexOf(v);
let num = 0;
let index_arr = [];
index_arr.push(index);
while (index !== -1) {
num++;
index = str.indexOf(v, index + 1);
if (index != -1) {
index_arr.push(index);
}
}
return index_arr;
}