How to create an internal search engine in html?

TaloBV

New member
Jun 3, 2020
2
0
1
Hello Community! How are they? I would like to make an inquiry:

I am creating a website purely in HTML and CSS and I want to incorporate an internal search engine that is capable of:
1) Find words or ID sections IN THE SAME html file (eg index.html) where the search engine is located.
2) Find words or ID sections in OTHER html files (ex: services.html)

I managed to do it from this code:


Code:
<head>

<script LANGUAGE="Javascript">
<!-- Buscador Interno Por www.Designs-web.es.tl  -->


<!-- inicio
var item = new Array();

/* aqui comiensa la magia.
    solo ingresa los codigos adicionales
    de lo que quieras buscar, y llenalos
    de keywords adicionales para mejorar la busqueda.
*/

// "Nombre De La Pagina","SubPaginas/Pagina(en caso de PWG esto va basio)","Titulo De Pagina","Muchos,Key,Words","Comentarios Descriptivos"

c=0; item[c]=new Array("inicio.html","","Inicio","index,main,start,home,front,inicio,portada","El inicio de mi sitio web.");
c++; item[c]=new Array("Contacto.htm","","Contacto","contacto,buscame","Enlase Para Contactarme.");

/* puedes ingresar tantas posiblidades desees de busqueda.
    solo ingresa mas de estos:
c++; item[c]=new Array("NombreDelaPagina.htm","","TitulodelaPagina","Key,words,de,la,pagina,separados,por,comas","y descripcion de la pagina.");

    en los keywords puedes poner las palabras mas importantes de la pagina de busqueda.
*/

page="<html><head><title>Resultados De La Busqueda</title></head><body bgcolor='white'><center>
<table border=0 cellspacing=10 width=80%>";


function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table>
<br>Resultados Totales: "+total+"<br><center>
Powered By Chaproducciones.Tk</center>
</body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "
<tr><td><a href='"+link+"'>"+item[which][2]+"</a> - Puntuacion: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>
";
wind.document.write(line);
return 1;
}
//  fin -->
</script>
</HEAD>
<!-- PASO DOS: copia despues de el codigo anterior  -->

<div style="position: absolute; left: 78px; top: 0px;">
<script>
<!--
document.write(unescape("%3CBODY%3E%0A%3Ccenter%3E%3Cform%20method%3Dget%20action%3D%22javascript%3Avoid%280%29%22%20onsubmit%3D%22search%28this%29%3B%20return%20false%3B%22%3E%0A%3Ctr%3E%3Ctd%3E%3Cinput%20type%3Dtext%20name%3Dsrchval%20value%3D%22%22%3E%3Cinput%20type%3Dsubmit%20value%3D%22Buscar%22%3E%3Cbr%3E%3Cfont%20face%3D%22arial%2C%20helvetica%22%20size%3D%22-2%22%3E%3Ca%20href%3D%22http%3A//chaproducciones.tk%22%20alt%3D%22Buscador%20Interno%20Por%20Chaproducciones.Tk%22%3EBuscador%20Interno%3C/a%3E%3C/font%3E%0A%3C/body%3E%3C/td%3E%3C/tr%3E%0A%3C/form%3E%0A%3C/center%3E"));
//-->
</script>

But I don't like how it looks aesthetically. It also forces you to open a pop-up window. I would like a more direct search engine.

Does anyone know how to modify the code for these purposes?
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu