/    Sign up×
Community /Pin to ProfileBookmark

the Search Site script doesn’t work

I tried testing this script out on one of my sites and the code has an error in it. A chunk of the code appears on my page even though it is in the head. I’m not sure if a period is missing or maybe a opening or closing tag, but something is causing it to appear on my page. I even went as far as to copy the script directly from the view source, but I’m getting the same problem.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Tasmanian_DevilFeb 26.2004 — razor~

I am not an expert by far, but it would be helpful if you could post your script or even have a working link a page.

Thanks

Devil
Copy linkTweet thisAlerts:
@razor2341authorFeb 26.2004 — <SCRIPT LANGUAGE="JavaScript">

<!-- Original: Dion ([email protected]) -->

<!-- Web Site: http://www.iinet.net.au/~biab -->

<!-- This script and many more are available free online at -->

<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

var item = new Array();

/* Here is where all the magic happens.


Just enter as many additional pages that

that you want to search, then fill in the

additional listings for each page.

*
/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("index.html","","DemoSite","index,main,start,home,front","Demonstration search engine data about an imagined but probable internet site.");

c++; item[c]=new Array("about.htm","","About Me","about,author,contact,email,who","Contact details and general information about the creator of the site and what the site is about.");

c++; item[c]=new Array("links.htm","","Links page","links,more,where,similar,friends","Links to my favourite sites which I find interesting. Other friends sites which have similar interests to my own.");

c++; item[c]=new Array("main.htm","main/","Main Page","content,main,focus","The main part of my site which contains what you have come to see. Lots of stuff like that and more great things. All in a sub directory.");

c++; item[c]=new Array("logo.jpg","main/images/","Link Logo","link,image,logo,graphic","The logo.jpg is just a small image which you can place on your site as a link to me. It's in a second level subdirectory.");

page="<html><head><title>Search Results</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>Total found: "+total+"<br></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> Score: "+num+"<br>";

line += item[which][4] + "<br>"+link+"</td></tr>";

wind.document.write(line);

return 1;

}

// End -->

</script>
Copy linkTweet thisAlerts:
@Tasmanian_DevilFeb 26.2004 — razor~

the following is a site search that I have used in the past see if it helps you out.

<head>

<title>Test</title>

<SCRIPT LANGUAGE="JavaScript">

function putFocus(formInst, elementInst) {

if (document.forms.length > 0) {

document.forms[formInst].elements[elementInst].focus();

}

}

</script>

<script language="JavaScript" type="text/javascript">

function checkCR(evt) {

var evt = (evt) ? evt : ((event) ? event : null);

var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

if ((evt.keyCode == 13) && (node.type=="text")) {return false;}


}

document.onkeypress = checkCR;

</script>

</head>

<body onLoad="putFocus(0,0);init()" BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000">

<tr>

<script

LANGUAGE="JavaScript">

Keyword = new Object();
Descrip = new Object();
Address = new Object();


// Keyword[0] = n (where n is the number of keywords which can be searched

Keyword[0] = 100

Keyword[1] = "test"

Descrip[1] = "Info<br>Address<br>Hours"

Address[1] = "http://www.yourdomain.com/pageITisAT.html"

Keyword[2] = "test"

Descrip[2] = "Info<br>Address<br>Hours"

Address[2] = "http://www.yourdomain.com/pageITisAT.html"

Keyword[3] = "test2"

Descrip[3] = "Info2<br>Address2<br>Hours2"

Address[3] = "http://www.yourdomain.com/pageITisAT2.html"

function checkDatabase() {

var Found = false
var Item = document.forms[0].searchfor.value.toLowerCase();


stats='toolbar=no,location=no,directories=no,status=no,menubar=no,height=300,width=400,'

stats += 'scrollbars=yes,resizable=no'

MsgBox = window.open ("","msgWindow",stats)

MsgBox.opener = window;

MsgBox.opener.name = "opener";

MsgBox.document.write("<head><title>Store Locator Results</title></head>");

MsgBox.document.write ("<body bgcolor=white text=black link=blue vlink=blue alink=blue background='http://www.midwestdeliveryservices.com/cnvbkgnd.bmp'><H2><CENTER><font face=arial>Store Locator Results</CENTER></H2>")

MsgBox.document.write ("<font size=3><b><center>For Stores In The City Of: "+Item+"</center><hr width=50%></b></font>");

for (var i=1; i <= Keyword[0]; i++) {

if(Item == Keyword[i]) {

Found = true;

MsgBox.document.write ("<li><font face=arial><font size=2><b>"+Descrip[i]+"<BR><A HREF="+Address[i]+" target='opener'>Click Here To Go A Map</A></font></font><br><br><br>")

}

}

if(!Found)

MsgBox.document.write ("<H4>No Info Found<br><br>Make Sure The Spelling Of The City Is Correct.<br><br><a href='http://www.yourdomain.com/anotherpage.html'>Click Here For A List Of Info.</a></H4>")

MsgBox.document.write ("<FORM><CENTER>")

MsgBox.document.write ("<font size=2><font color=arial><INPUT type='button' value='Close' onClick = 'self.close()'></font></font>")

MsgBox.document.write ("</CENTER></FORM>")

}

</script>


<form NAME="form1">

<div align="center">

<center>

<br>

<p><b><font size="3">Search For Info On:</font></b>

<br>

<input TYPE="text" NAME="searchfor" VALUE="" SIZE="20"><b><input type="button"

value="Locate Stores" align="absmiddle" onClick="checkDatabase()"></b><br>



</p>
</center></div>
</form>

</body>

</html>

It will need a little working done to it to suite your needs. Hope it helps.

Thank

Devil
×

Success!

Help @razor2341 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...