PDA

View Full Version : Help with New Window + Search Function



Ingla
10-06-2005, 03:05 PM
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 managed 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. :confused:

If anyone could help (in baby talk for a javascript newbie..maybe just add to this code in bold or red or something?), I'd surely 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">&nbsp;
<!--<td width="100" bgcolor=lightblue><font size=1 face="Verdana, Arial, sans-serif">&nbsp;-->


<tr>
<td bgcolor=navajowhite><input style="background: dddddd" size="2" name="searchText" type="text"><!--<br><p>-->
<td bgcolor=navajowhite>
<select width="2" name="whichEngine"
&nbsp;
//!<onchange="startSearch()">


<option >Altavista</option>


<option>Galaxy</option>

<option selected>Google</option>

<option>Lycos</option>

<option>Yahoo!</option>
&nbsp;<br>


<td bgcolor=navajowhite valign="bottom">&nbsp;<br>
<input type="button" value="Go" onClick="startSearch()">

</select></form>
</table>
---------------------------------------------------------------

Thanks very much.
Ingla

huangpower
11-02-2005, 09:34 PM
To make results open in NEW window, replace:

(use find function)

location.href = finalSearchString;}}// -->

with:

NewWin = window.open(finalSearchString);}}// -->