Forum Moderators: open
www.mysite.com/search.cgi?q=scarab+beetles+and+culture+symbols
Needless to say, this would be much more efficient if done at the server side, but it can be done.
<script language="javascript">
<!--
query=window.location.href.split("q=").split("&")[0];//Here, put as many addresses as you want, and where you want the query search, put ###. For the text to display the link as, put that before the percent (%) sign.
urls=new Array("Search Google for ###%http://www.google.com/search?hl=en&q=###","Search Dictionary.com for ###%http://www.dictionary.com/search?q=###");
for(var quick=0;quick<urls.length;quick++)
{
hurry=urls[quick].replace(/\#\#\#/g,query);
document.write("<a href=\""+hurry.split("%")[1]+"\">"+hurry.split("%")[0]+"</a><br>");}
//-->
</script>
Certainly, it can be cleaned up a bit, but it should work.
[1][edited by: adni18 at 4:51 pm (utc) on Dec. 29, 2004]
<script type="text/javascript">
function searchwith(se) {
var kw = document.myform.query.value;
switch (se) {
case 'g' : location = 'http://www.google.com/search?q=' + kw; break;
case 'y' : location = 'http://search.yahoo.com/search?p=' + kw; break;
}
}
</script>
<form name="myform">
<input type="text" name="query" value="widget">
...
</form>
<a href="http://www.google.com/" onclick="searchwith('g'); return false">search with Google</a>
<a href="http://www.yahoo.com/" onclick="searchwith('y'); return false">search with Yahoo</a>
<script language="javascript">
<!--
query=window.location.href.split("q=")[1].split("&")[0];
//Here, put as many addresses as you want, and where you want the query search, put ###. For the text to display the link as, put that before the percent (%) sign.urls=new Array("Search Google for ###%http://www.google.com/search?hl=en&q=###","Search Dictionary.com for ###%http://www.dictionary.com/search?q=###");
for(var quick=0;quick<urls.length;quick++)
{
hurry=urls[quick].replace(/\#{3}/g,query);
document.write("<a href=\""+hurry.split("%")[1]+"\">"+hurry.split("%")[0]+"</a><br>");
}
//-->
</script>
<script language="javascript">
<!--
query=window.location.href.split("q=")[1].split("&")[0];
//Here, put as many addresses as you want, and where you want the query search, put ###. For the text to display the link as, put that before the percent (%) sign. Use a *** for the human-readable queryurls=new Array("Search Google for ***%http://www.google.com/search?hl=en&q=###","Search Dictionary.com for ***%http://www.dictionary.com/search?q=###");
for(var quick=0;quick<urls.length;quick++)
{
hurry=urls[quick].replace(/\#{3}/g,query);
readable=hurry.split("%")[0].replace(/\*{3}/g,unescape(query.replace(/\+/g," ")));
document.write("<a href=\""+hurry.split("%")[1]+"\">"+readable+"</a><br>")
}
//-->
</script>