Loading ...
Sorry, an error occurred while loading the content.
 

addEventListener

Expand Messages
  • immanuel_normann
    Hallo, who is familiar with addEventListener ? It has w3.org DOM specification and a javascript binding in Mozilla. But all given examples, don t solve my
    Message 1 of 1 , Sep 4, 2002
      Hallo,

      who is familiar with 'addEventListener'?
      It has w3.org DOM specification and a javascript binding in Mozilla.

      But all given examples, don't solve my problem:

      If I have the situation of

      <any-element onClick = "foo(x,y)">...

      a click on this element evokes foo(x,y).

      Now I have just

      <any-element>.....

      and want to bind dynamically alert('you clicked')

      They only way how to do so - as far as I know - is long-winded:

      Assume elem is that <any-element> then
      elem.addEventListener("click", doSomething, false)
      with
      function doSomething() {foo(x,y)}
      does the job.

      This is of course redundant. It would be more convenient to have just:

      elem.addEventListener("click", foo(x,y), false)

      but this does NOT work!!! WHY?
      Is it a deficiency of javascript?

      Immanuel
    Your message has been successfully submitted and would be delivered to recipients shortly.