Forum Moderators: open

Message Too Old, No Replies

javascript multi search engine ...

         

StopSpam

5:37 pm on Jul 5, 2003 (gmt 0)

10+ Year Member



I got this javascript wish allow search in multi search engines ...

Unfortualy if you look at code it only works if keyword is placed a end off search engine url ..

now i wish to add a new search engine but the keyword is not at the end of url .. and search only works if words behind keyword are added ..how can i add the required info at end of keyword .. i must add this: ?=search&ON

this url i wish to add:
[searchengine.com...]

Keyword-here is were keyword goes..
but as you see it requires info behind keyword.

now can i add this or fit this url in bellow script with code after keyword.

im looking forward to your reply

===

<title>Quick Search on Multiple Search Engines</title>
<script language="JavaScript" type="text/javascript">
<!--
var crawlername = new Array("Google","Yahoo","Altavista (Raging)");
var crawleraction = new Array("http://www.google.com/search?q=","http://search.yahoo.com/bin/search?p=","http://www.altavista.com/sites/search/res_text?q=");

function populateCrawlers()
{
var d=0,startcount=0,option;
for (d=0;d<crawlername.length;d++)
{
option = new Option(crawlername[d],crawleraction[d]);
document.search.crawler.options[startcount] = option;
startcount++;
}
}

function initiateSearch(x)
{
var url;
url = x.crawler.options[x.crawler.selectedIndex].value+x.q.value;
self.location.href = url;
return (false);
}
//-->
</script>

</head>
<body onLoad="populateCrawlers()">
<h4 align="center">Quick Search On Various Search Engines</h4>
<form method="GET" name="search" onSubmit="return initiateSearch(this)">
<table summary="Search" width="50%" align="center">
<tr>
<th align="right">Search:</th>
<th align="left">
<input type="text" name="q" size="10" maxlength="100">&nbsp;&nbsp;<input type="submit" value="GO">
</th>
</tr>
<tr>
<th align="right">Use:</th>
<th align="left">
<Select name="crawler">
</Select>
</th>
</tr>
</table>
</form>

tedster

7:12 am on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you only want to use three search engines, then the array construction is overkill -- you could just hand code each option.

But if you intend to add more search engines, you will probably find other "custom" configurations for the URL. So I'd suggest populating a third array for the tag ends that fall after the search term -- call it "crawlertag[]" or something like that. If the option involved ends with the search term, have that array element be a null value.

Then when you construct your "url" variable, just add the crawlertag[] element to the tail end. Does that seems sensible to you?

StopSpam

11:07 am on Jul 6, 2003 (gmt 0)

10+ Year Member



yes this sounds like what i want but i have noidea how to make this .. i dont know javascript coding ...

i only hav small perl skills

Thanasus

11:25 am on Jul 6, 2003 (gmt 0)

10+ Year Member



Well, what you add will vary depending on the engine. Lets say you wanted to add the FAST engine... well, go to alltheweb.com and do a search. I did one for 'test'. After you click the search button and get your first list of results, look at the URL in the address bar:

[alltheweb.com...]

Note the part that reads 'q=test'. Well, move that to the end

[alltheweb.com...]

Then just remove your keyword

[alltheweb.com...]

THat is the string you would add into the javascript:

var crawlername = new Array("Google","Yahoo","Altavista (Raging)","FAST");

var crawleraction = new Array(
"http://www.google.com/search?q=",
"http://search.yahoo.com/bin/search?p=",
"http://www.altavista.com/sites/search/res_text?q=",
"http://www.alltheweb.com/search?cat=web&cs=utf-8&_sb_lang=en&q=");