/    Sign up×
Community /Pin to ProfileBookmark

Fun little search utility could use some improvements.

Hi all,

I just wanted to share a search script that I made and find useful. I’m a bit of a js newb so one ~obvious improvements is to have the form submit when someone hits the enter button (maybe default to Google), but I have not yet figured out how to do that. There’s also a lot of redundant code in it, so there’s probably a cleaner approach that I haven’t though out yet. Beyond that, I think it’s a fun little script and I wanted to share it with the group. I know there’s some creative people here and maybe you have an idea or two regarding new features or uses for it. I’d also like to hear some additional search engines that you’d like to see implemented.

Thanks.
John

[CODE]

<html>
<style type=”text/css”>
form {padding:0; margin:0;}
</style>

<head>
<title>Multi-Search</title>
<script type=”text/javascript”>
<!–

function wikipedia(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + ” http://en.wikipedia.org/wiki/” + f + “‘ width=’100&#37;’ height=” + ifHeight +”></iframe>”
}

function google(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://www.google.com/search?q=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function bing(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://www.bing.com/search?q=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function clusty(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://clusty.com/search?input-form=clusty-simple&v%3Asources=webplus&query=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function wolfram(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://www.wolframalpha.com/input/?i=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function delicious(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://delicious.com/search?p=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

/*
function twitter(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://search.twitter.com/search?q=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}
*/

function ebay(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://shop.ebay.com/?_from=R40&_trksid=p3907.m38.l1313&_nkw=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function amazon(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function craigslist(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://raleigh.craigslist.org/search/sss?query=” + f + “‘ width=’100%’ height=” + ifHeight +”></iframe>”
}

function googleSets(form){
document.getElementById(“top”).innerHTML =””;
var f = form.input.value;
var s = “”;
for(var i=0; i<f.length; i++){
if(f.charAt(i) != ” “){s = s + f.charAt(i)}
else{s = s + “&q2=”}
}
document.getElementById(“1”).innerHTML = “<iframe id=’test’ src ='” + “http://labs.google.com/sets?hl=en&q1=” + s + “‘ width=’100%’ height=’500′></iframe>”;
//Example URL for javascript and dom: http://labs.google.com/sets?hl=en&q1=javascript&q2=dom
}

document.getElementById(“1″).innerHTML =”<iframe name=’frm’ width=’100%’ height=’100%’ marginwidth=’0′ marginheight=’0′></iframe>”;
//document.getElementById(“1″).innerHTML =”<iframe name=’frm’ width=’100%’ height=’100%’ ></iframe>”;
}

//–>
</script>
</head>
<body onload = ‘ifHeight= window.innerHeight-15’; onresize = ‘ifHeight = window.innerHeight-15’; >

<table border=”0″cellpadding=”0″ width=100% height=100%>
<tr>
<td valign=”top”>

<FORM >
<INPUT NAME=”input” VALUE=”” MAXLENGTH=”2000″ SIZE=22><br>
<INPUT NAME=”calc” VALUE=”Google” TYPE=BUTTON onClick=google(this.form)>
<INPUT NAME=”calc” VALUE=”bing” TYPE=BUTTON onClick=bing(this.form)>
<INPUT NAME=”calc” VALUE=”Wikipedia” TYPE=BUTTON onClick=wikipedia(this.form)>
<INPUT NAME=”calc” VALUE=”Clusty” TYPE=BUTTON onClick=clusty(this.form)>
<INPUT NAME=”calc” VALUE=”Wlfrm|Alph” TYPE=BUTTON onClick=wolfram(this.form)>
<INPUT NAME=”calc” VALUE=”delicious” TYPE=BUTTON onClick=delicious(this.form)>
<INPUT NAME=”calc” VALUE=”eBay” TYPE=BUTTON onClick=ebay(this.form)>
<INPUT NAME=”calc” VALUE=”amazon” TYPE=BUTTON onClick=amazon(this.form)>
<INPUT NAME=”calc” VALUE=”craigslist” TYPE=BUTTON onClick=craigslist(this.form)>
<INPUT NAME=”calc” VALUE=”Google Sets” TYPE=BUTTON onClick=googleSets(this.form)>
<!–<INPUT NAME=”calc” VALUE=”Forums” TYPE=BUTTON onClick=forums(this.form)> –>

<div id=”form”></div>
</FORM>

</td>
<td width=100% height=100%>
<div id = “top”>top</div>
<div id = “1”></div>

</td>
</tr>
</body>
</html>
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameAug 05.2009 — Looks to me as if you paid no attention to or did not see this:

http://www.webdeveloper.com/forum/showthread.php?t=209217
×

Success!

Help @JohnJRI 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...