• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

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?
 

Forum statistics

Threads
79,277
Messages
1,138,184
Members
247,737
Latest member
stasmartyn
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock