Results 1 to 2 of 2

Thread: Search From Google

  1. #1
    Join Date
    Jan 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Search From Google

    I was wondering how I would create a little search engine using javascript. What it will do is it will allow you to type a word in a box and press search and then when you click the button a new window will open and load the search in google.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    No javascript required:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <form action="http://www.google.com/search" method="get" target="_blank">
    Search: <input type="text" name="q"> <input type="submit" value="Go!">
    </form>
    </body>
    </html>
    However, javascript can be used to enhance control over the window:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function ogoo(e){
    if (e&&(e.type=='click'||window.event&&e.keyCode&&e.keyCode==13)){
    ogoo.win=window.open('','goowin','height=400, width=550');
    ogoo.win.focus();
    }
    }
    </script>
    </head>
    <body>
    <form action="http://www.google.com/search" method="get" target="goowin">
    Search: <input type="text" name="q" onkeydown="ogoo(event);return true;">
     <input onclick="ogoo(event);return true;" type="submit" value="Go!">
    </form>
    </body>
    </html>
    Last edited by jscheuer1; 01-26-2008 at 05:07 PM. Reason: upgrade code
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •