Google Search not working

Discussion in 'Javascript' started by tshad, Sep 20, 2006.

  1. tshad

    tshad Guest

    I have the following page I found on the net, but it doesn't work. I get an
    error on page.

    ******************************************************************
    <html>
    <head>

    <SCRIPT LANGUAGE=JAVASCRIPT>
    function googleSearch() {
    if (document.doingasearch.searchbox.value!="") {
    window.open("http://www.google.com/search?hl=en&q="; +
    document.doingasearch.searchbox.value) ;
    }
    else {
    alert("Please enter something to search.")
    }
    }
    </SCRIPT>
    </head>

    <body bgcolor="#FFFFFF">
    <FORM name="doingasearch" id="doingasearch">
    Google
    <INPUT name=searchbox type=text size=20>
    <INPUT type="button" value="Search" onclick="return googleSearch();">
    </FORM>
    </body>
    </html>
    *************************************************************************************
    I thought maybe the semicolon in the window.open line was the problem but it
    wasn't.

    Can anyone see the problem with this?

    Thanks,

    Tom
    tshad, Sep 20, 2006
    #1
    1. Advertising

  2. tshad wrote:
    > I have the following page I found on the net, but it doesn't
    > work. I get an error on page.


    If you click that "error on page" icon a dialog will appear that will
    tell you what the error was. (even if you don't understand it someone
    here may).

    > ****************************************************
    > <html>
    > <head>
    >
    > <SCRIPT LANGUAGE=JAVASCRIPT>
    > function googleSearch() {
    > if (document.doingasearch.searchbox.value!="") {
    > window.open("http://www.google.com/search?hl=en&q="; +

    <snip> ^

    That semicolon before the plus sign is a syntax error.

    Richard.
    Richard Cornford, Sep 20, 2006
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "Richard Cornford" <> wrote in message
    news:...
    > tshad wrote:
    >> I have the following page I found on the net, but it doesn't
    >> work. I get an error on page.

    >
    > If you click that "error on page" icon a dialog will appear that will
    > tell you what the error was. (even if you don't understand it someone
    > here may).


    The error I got was:

    Line: 20
    Error: Object expected
    Code: 0

    Line 20 is:

    <INPUT type="button" value="Search" onclick="return googleSearch();">

    Thanks,

    Tom
    >
    >> ****************************************************
    >> <html>
    >> <head>
    >>
    >> <SCRIPT LANGUAGE=JAVASCRIPT>
    >> function googleSearch() {
    >> if (document.doingasearch.searchbox.value!="") {
    >> window.open("http://www.google.com/search?hl=en&q="; +

    > <snip> ^
    >
    > That semicolon before the plus sign is a syntax error.
    >
    > Richard.
    >
    tshad, Sep 20, 2006
    #3
  4. tshad wrote:
    > Richard Cornford wrote:
    >> tshad wrote:
    >>> I have the following page I found on the net, but it
    >>> doesn't work. I get an error on page.

    >>
    >> If you click that "error on page" icon a dialog will
    >> appear that will tell you what the error was. (even
    >> if you don't understand it someone here may).

    >
    > The error I got was:
    >
    > Line: 20
    > Error: Object expected
    > Code: 0
    >
    > Line 20 is:
    >
    > <INPUT type="button" value="Search"
    > onclick="return googleSearch();">


    And the previous button on the dialog will show the syntax error that I
    pointed out, which stops the "expected" function from being defined.

    Richard.
    Richard Cornford, Sep 20, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=

    Google search result like site search!! How?

    =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    654
    Lucas Tam
    May 6, 2005
  2. Andrew Thompson

    FAQ - references to Google/Google Groups

    Andrew Thompson, Jun 20, 2005, in forum: Java
    Replies:
    0
    Views:
    593
    Andrew Thompson
    Jun 20, 2005
  3. Chris K.
    Replies:
    3
    Views:
    723
    Chris K.
    Jun 8, 2008
  4. Abby Lee
    Replies:
    5
    Views:
    374
    Abby Lee
    Aug 2, 2004
  5. Replies:
    2
    Views:
    335
Loading...

Share This Page