how google suggest works -- which event is attached to INPUT element

Discussion in 'Javascript' started by wolverine, Sep 6, 2007.

  1. wolverine

    wolverine Guest

    Hi,
    Hope every body uses google suggest http://www.google.com/webhp?complete=1&hl=en.
    For every key press in the input box google would offer suggestions. I
    wanted to see which event is attached to the the INPUT element.

    Since the element is inside the form 'f' and it's name is 'q'. So i
    accessed it as
    javascript:alert(document.f.q.onkeypress) from address bar

    The problem is in Mozilla FireFox it is correctly giving me the
    handler attached but in IE it was giving me 'null' indicating that
    onkeypress is not attached. So i tried with 'onkeydown' and 'onkeyup'
    as well. Both of them in IE returned null. So how does IE detect that
    a key has been pressed.

    So my doubt is a key event attached by google suggest in IE or google
    suggest is using some other means to detect that a key event has
    happened.

    In case a key event is attached in IE, how to verify that it has been
    really attached ? Could any one of you help me in this matter .

    Thanks in Advance
    Kiran.
    wolverine, Sep 6, 2007
    #1
    1. Advertising

  2. Re: how google suggest works -- which event is attached to INPUTelement

    Randy Webb wrote:
    > View the source.
    > [...]
    > Why not view the source?
    > [...]
    > Try viewing the source.....


    YMMD :)


    Regards,
    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Sep 6, 2007
    #2
    1. Advertising

  3. wolverine

    wolverine Guest

    On Sep 6, 8:25 pm, Randy Webb <> wrote:
    > wolverine said the following on 9/6/2007 9:33 AM:
    >
    > > Hi,
    > > Hope every body uses google suggesthttp://www.google.com/webhp?complete=1&hl=en.

    >
    > I don't, I find it very annoying.


    If every body was the same world would be very boring.

    >
    > > For every key press in the input box google would offer suggestions. I
    > > wanted to see which event is attached to the the INPUT element.

    >
    > View the source.


    I was unable to find it by viewing the source. You are a genius if you
    could do that by viewing
    source. Prove it if you could understand that by viewing the source

    >
    > > Since the element is inside the form 'f' and it's name is 'q'. So i
    > > accessed it as
    > > javascript:alert(document.f.q.onkeypress) from address bar

    >
    > Why not view the source?


    I was unable to find it by viewing the source. You are a genius if you
    could do that by viewing
    source. Prove it if you could understand that by viewing the source


    >
    > > In case a key event is attached in IE, how to verify that it has been
    > > really attached ? Could any one of you help me in this matter .

    >
    > Try viewing the source.....


    I was unable to find it by viewing the source. You are a genius if you
    could do that by viewing
    source. Prove it if you could understand that by viewing the source



    >
    > --
    > Randy
    > Chance Favors The Prepared Mind
    > comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
    > Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
    wolverine, Sep 7, 2007
    #3
  4. wolverine

    marss Guest

    On 6 , 18:25, Randy Webb <> wrote:

    > View the source.
    > [...]
    > Why not view the source?
    > [...]
    > Try viewing the source.....


    A good answer as for a person who is somewhat of an expert/moderator.
    Keep it up that way, you make this newsgroup very cognitive.
    marss, Sep 7, 2007
    #4
  5. wolverine

    marss Guest

    On 6 , 16:33, wolverine <> wrote:

    > javascript:alert(document.f.q.onkeypress) from address bar


    You can see a function attached to an event only if it set directly:
    e.g.
    q.onkeypress = someFuntion;
    or
    <input onkeypress="someFuntion()" ...

    You can't see event handlers that are attached by attachEvent or
    addEventListener

    Regards,
    Mykola
    http://marss.co.ua
    marss, Sep 7, 2007
    #5
  6. wolverine

    wolverine Guest

    On Sep 7, 1:30 pm, marss <> wrote:
    > On 6 , 16:33, wolverine <> wrote:
    >
    > > javascript:alert(document.f.q.onkeypress) from address bar

    >
    > You can see a function attached to an event only if it set directly:
    > e.g.
    > q.onkeypress = someFuntion;
    > or
    > <input onkeypress="someFuntion()" ...
    >
    > You can't see event handlers that are attached by attachEvent or
    > addEventListener
    >


    You got it. That is what i meant.

    Even before posting the question i viewed the source and was not able
    to find any of the first 2 ways you suggested. Actually my question
    was how to find events added addEventListener in IE?


    > Regards,
    > Mykolahttp://marss.co.ua
    wolverine, Sep 7, 2007
    #6
  7. wolverine

    marss Guest

    On 7 , 12:10, wolverine <> wrote:

    > > You can't see event handlers that are attached by attachEvent or
    > > addEventListener

    >
    > You got it. That is what i meant.
    >
    > Even before posting the question i viewed the source and was not able
    > to find any of the first 2 ways you suggested. Actually my question
    > was how to find events added addEventListener in IE?


    Would you say: "events added attachEvent in IE"? (addEventListener is
    for Firefox)
    If you can't find it in the page source then look through included
    javascript files.
    It is only way. Reverse engineering is not easy occupation.

    Regards,
    Mykola
    http://marss.co.ua
    marss, Sep 7, 2007
    #7
  8. wolverine

    marss Guest

    On 7 , 12:10, wolverine <> wrote:

    > Even before posting the question i viewed the source and was not able
    > to find any of the first 2 ways you suggested.


    In the page source:
    window.google.ac.InstallAC(document.f,document.f.q,document.f.btnG,"search","en");

    In the included file http://www.google.com/extern_js/f/CgJlbiswCjgBLA/vST7u151leI.js:
    r.InstallAC=function(a,b,c,e,d,g,i,j,D)...

    Regards,
    Mykola
    http://marss.co.ua
    marss, Sep 7, 2007
    #8
  9. wolverine

    wolverine Guest

    On Sep 7, 2:32 pm, marss <> wrote:
    > On 7 , 12:10, wolverine <> wrote:
    >
    > > > You can't see event handlers that are attached by attachEvent or
    > > > addEventListener

    >
    > > You got it. That is what i meant.

    >
    > > Even before posting the question i viewed the source and was not able
    > > to find any of the first 2 ways you suggested. Actually my question
    > > was how to find events added addEventListener in IE?

    >
    > Would you say: "events added attachEvent in IE"? (addEventListener is
    > for Firefox)
    > If you can't find it in the page source then look through included
    > javascript files.
    > It is only way. Reverse engineering is not easy occupation.


    True. I was unable to reverse engineer it. So only i posted it in this
    groups. I know this groups is
    not the place to get my home work done. I just wanted to know any
    other means of checking whether an event is attached to an element in
    IE. But a guy named "Randy Webb" completely misunderstood the
    question and asked me to view the source which i had done in the first
    place. Partly it was my
    mistake of not putting down my question in crystal clear words. Any
    way thanks for the help.

    >
    > Regards,
    > Mykolahttp://marss.co.ua
    wolverine, Sep 7, 2007
    #9
  10. wolverine

    Noah Sussman Guest

    On Sep 7, 5:10 am, wolverine <> wrote:
    > Actually my question
    > was how to find events added addEventListener in IE?


    Afaik there is no way to find out which events have been attached
    using addEventListener.

    So, as was suggested above, you would have to read the code. In
    Firefox, you can use the Web Developer Toolbar's Information menu
    (https://addons.mozilla.org/en-US/firefox/addon/60) to dump all of the
    scripts associated with the page. That will give you a convenient, in-
    browser way to read through everything and find the place where the
    event is attached to the input field for IE.

    I would suggest that you search for calls to addEventListener. Look
    at the parameter list for each call, so that you can find where the
    input field is being passed. Since the input field does not have an
    ID, you will have to figure out how the Google devs passed that DOM
    element to their script.
    Noah Sussman, Sep 7, 2007
    #10
    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. guoqi zheng

    google suggest, how can I do this?

    guoqi zheng, Apr 12, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    488
    Karl Seguin
    Apr 12, 2005
  2. =?Utf-8?B?V2FyYW4=?=

    Auto-Suggested Textbox like google auto suggest

    =?Utf-8?B?V2FyYW4=?=, Apr 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    8,509
    inrakeshworld
    Jul 27, 2007
  3. Ali
    Replies:
    2
    Views:
    380
  4. Replies:
    5
    Views:
    121
    Dr John Stockton
    Nov 23, 2005
  5. Replies:
    3
    Views:
    95
Loading...

Share This Page