[thelist] Javascript Help - New Window + Search Function
Administrative HQ
english_offline at yahoo.com
Thu Oct 6 11:54:49 CDT 2005
Hello.
I've got this javascript search engine working on a
site.
The problem is I don't know much javascript, but have
managed to get it to work. BUT I need the search to
open in a new window.
Trying various coding to open a window, I've succeeded
to get a blank window to come up, but it's blank! I
can't get the search results to appear in the new
window. I've found no help on the web for getting
onclick to do two things at once. The usual way of
giving the new window a URL doesn't seem right because
the "submit" button calls a function.
If anyone could help (in baby talk for a javascript
newbie... or, maybe, just add to this code in bold or
red or something?), I'd appreciate it.
The search engine code is:
------------------------------------------------------
<script language="JavaScript" type="text/javascript">
//<![CDATA[
<!--
function startSearch(){searchString =
document.searchForm.searchText.value;if(searchString
!= ""){searchEngine =
document.searchForm.whichEngine.selectedIndex +
1;finalSearchString = "";
if(searchEngine == 1){finalSearchString =
"http://www.altavista.com/cgi-bin/query?pg=q&what=web&q="
+ searchString;}
if(searchEngine == 2){finalSearchString =
"http://www.galaxy.com/cgi-bin/query?keys=" +
searchString;}
if(searchEngine == 3){finalSearchString =
"http://www.google.com/search?q=" + searchString +
"&btnG=Google+Search";}
if(searchEngine == 4){finalSearchString =
"http://www.lycos.com/cgi-bin/pursuit?query=" +
searchString + "&backlink=639";}
if(searchEngine == 5){finalSearchString =
"http://search.yahoo.com/bin/search?p=" +
searchString;}
if(searchEngine == 18){finalSearchString =
"http://de.search.yahoo.com/search/de?p=" +
searchString;}location.href = finalSearchString;}}//
-->
//]]>
</script>
<form name="searchForm">
<table width="200" border cellpadding=3 cellspacing=2
bgcolor="#ebebeb">
<tr>
<td width="75" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">Search<br> for:<br>
<td width="100" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">Search<br> from:
<td width="25" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">
<!--<td width="100" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif"> -->
<tr>
<td bgcolor=navajowhite><input style="background:
dddddd" size="2" name="searchText"
type="text"><!--<br><p>-->
<td bgcolor=navajowhite>
<select width="2" name="whichEngine"
//!<onchange="startSearch()">
<option >Altavista</option>
<option>Galaxy</option>
<option selected>Google</option>
<option>Lycos</option>
<option>Yahoo!</option>
<br>
<td bgcolor=navajowhite valign="bottom"> <br>
<input type="button" value="Go"
onClick="startSearch()">
</select></form>
</table>
------------------------------------------------------
Thanks very much.
David
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/
More information about the thelist
mailing list