Hey,
i got a code from javascript.internet.com which lets you make a custom site search, the only problem is the results open in new window. Can someone please edit the code so it opens in the same window- i will credit if you like.
[B][U]CODE:
[CODE]<body link=”0000ff” vlink=”#0000ff” alink=”#ffffff” text=”#000000″ bgcolor=”#737373″>
<!– TWO STEPS TO INSTALL SITE SEARCH:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document –>
<!– STEP ONE: Paste this code into the HEAD of your HTML document –>
<HEAD>
<script language=”JavaScript”>
<!–
function SymError()
{
return true;
}
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
//–>
</script>
<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(“downloads.htm”,””,”Downloads”,”games,programs,screensavers,metal-games,play”,”This page this all the games, programs and screensavers on”);
c++; item[c]=new Array(“contact.htm”,””,”Contact”,”Contact,Help,form,questions”,”Contact the metal-games admin for comments, questions or any other things.”);
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><font size=’18’ color=’ff0000′>Search reselts</font><br><br><br><table border=1 bgcolor=dddddd cellspacing=2 width=85%>”;
function search(frm) {
win = window.top();
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><br><br><br><br><br><a href=http://www.metal-games.co.nr>Return to metal-games</a></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> Relative: “+num*10+”%<br>”;
line += item[which][4] + “<br>”+link+”</td></tr>”;
wind.document.write(line);
return 1;
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document –>
<BODY>
<center>
<form method=get action=”javascript:void(0)” onsubmit=”search(this); return false;”>
<tr><td><input type=text name=srchval value=”” size=’10’><input type=submit value=”Search”></td></tr>
</form>
<br>
<br>
<!– TWO STEPS TO INSTALL CENTERED POP-UP WINDOW:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document –>
<!– STEP ONE: Paste this code into the HEAD of your HTML document –>
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascript.internet.com –>
<!– Begin
var win = null;
function newWindow(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = ‘height=’ + h + ‘,’;
settings += ‘width=’ + w + ‘,’;
settings += ‘top=’ + wint + ‘,’;
settings += ‘left=’ + winl + ‘,’;
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document –>
<BODY>
<a href=”#null” onClick=”newWindow(‘http://www.freewebs.com/metal-games/search-help.htm’,”,’150′,’150′,’scrollbars’)”>Site search help</a>
<!–
Informational purposes only –
// Variables:
// 750 – width
// 450 – height
// resizable – window can be resized
// scrollbars – window displays the scrollbar on the right
// status – window displays the status bar at the bottom
// toolbar – window displays the toolbar at the top
// Note: href=”#null” makes the link display as a link. Don’t leave it out!
–>
<!– Script Size: 1.60 KB –>
</center>
<script language=”JavaScript”>
<!–
var SymRealOnLoad;
var SymRealOnUnload;
function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}
function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}
SymRealOnLoad = window.onload;
window.onload = SymOnLoad;
//–>
</script>
thanks,
–[B]Steven