SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: I need help

  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    UK
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need help

    I need help please. I need this code to open a search in a new window. Any suggestions?

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Search the web</title>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" onload="addOptions()">
    <script language="javascript">

    // Initialize array
    var arr = new Array();
    arr[arr.length] = new Array("Search The Web");
    arr[arr.length] = new Array("Popular=================");
    arr[arr.length] = new Array("Aol", "http://search.aol.com/dirsearch.adp?query=");
    arr[arr.length] = new Array("Alta Vista", "http://www.altavista.com/cgi-bin/query?kl=XX&pg=q&Translate=on&q=");
    arr[arr.length] = new Array("Excite", "http://search.excite.com/search.gw?search=");
    arr[arr.length] = new Array("Google", "http://www.google.com/search?q=");
    arr[arr.length] = new Array("Hot Bot", "http://hotbot.lycos.com/?SM=MC&DV=0&LG=any&DC=10&DE=2&AM1=MC&MT=");
    arr[arr.length] = new Array("Looksmart", "http://www.looksmart.com/r_search?look=&pin=000925x015ff3eb1aa75d53e11&key=");
    arr[arr.length] = new Array("Lycos", "http://search.lycos.com/default.asp?lpv=1&loc=searchhp&tab=web&query=");
    // etc...

    // Add options to list
    function addOptions()
    {
    var sel = document.searchForm.whichEngine;
    for(var i = 0; i < arr.length; i++)
    {
    sel.options[i] = new Option(arr[i][0], i);
    }
    }

    // Get url for search engine
    function startSearch()
    {
    searchString = document.searchForm.searchText.value;
    if(searchString != "")
    {
    var searchEngine = document.searchForm.whichEngine.selectedIndex;
    var finalSearchString = arr[searchEngine][1] + searchString;
    location.href = finalSearchString;
    }
    return false;
    }

    // Check if key pressed == enter
    function checkKey()
    {
    if(window.event.keyCode == '13')
    {
    return startSearch();
    }
    else return true;
    }

    </script>


    <form name="searchForm">
    <div align="center"><b>Search the web ></b>
    <input name="searchText" type="text" onkeypress="return checkKey()"/>
    <select name="whichEngine" style="background-color: #F5F5F5; font-weight: bold">
    </select>
    <input type="button" value="Search" onClick="return startSearch()"/>
    <br>
    </div>
    </form>
    </body>

  2. #2
    SitePoint Addict
    Join Date
    Jul 2000
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try adding a target to your form tag
    HTML Code:
    <form name="searchForm" target="_blank">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •