Active Topics

 



Notices


Reply
Thread Tools
Posts: 46 | Thanked: 36 times | Joined on Sep 2008
#1
http://files.myopera.com/q335r49/files/Google.htm

Nothing major, but a javascript homepage that implements a keyword search, a la firefox. Type "wp?bats" to search bats on wikipedia -- other sites can be added by making copying and altering the 'else-if' block, its a fairly trivial process

else if(split[0]=="wp")
SearchSite = "http://en.wikipedia.org/wiki/search?search=%s&go=Go"

wp is the keyword
http://en.wikipedia.org/wiki/search?search=%s&go=Go is the url
%s is the search string

This is my first javascript script, so if anyone can automate this process (such as with an "add/remove/list search" function, or prettify the layout) that would be sweet

code:

<HTML><HEAD><SCRIPT LANGUAGE="JavaScript">
if (document.layers)
document.captureEvents(Event.KEYDOWN);
document.onkeydown = function (evt)
{ var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keycode
if (keyCode == 13)
{ split = document.form1.text1.value.split("?")
if(split[0]=="g")
SearchSite = "http://www.google.com/search?q=%s"
else if(split[0]=="wp")
SearchSite = "http://en.wikipedia.org/wiki/search?search=%s&go=Go"
else if(split[0]=="az")
SearchSite = "http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=%s&x=0&y=0"
else if(split[0]=="")
SearchSite = "http://www.google.com/search?hl=en&q=%s&btnI=I%27m+Feeling+Lucky&aq=f&oq ="
window.location = SearchSite.replace("%s",split[1])
return false
} else
return true
} </SCRIPT></HEAD>
<BODY onLoad="document.form1.text1.focus()">
<table width="100%" height="100%">
<tr><td align="absmiddle"><FORM name="form1">
<INPUT NAME="text1" style="font-size:24px" TYPE=Text Value="?">
</FORM></td></tr></BODY></HTML>

Last edited by q335r49; 2008-09-27 at 22:26. Reason: Better layout
 

The Following User Says Thank You to q335r49 For This Useful Post:
Reply

Tags
custom search, keyword search, search


 
Forum Jump


All times are GMT. The time now is 04:33.