pass event as parameter to a dynamically assigned eventHandler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r_o
    New Member
    • Jul 2006
    • 35

    pass event as parameter to a dynamically assigned eventHandler

    hi all,
    i'm trying to dynamically assign an event handler for an onmouseover event on a <Li> element.
    i need to pass the event as a parameter to the handler as follows
    <script language="javas cript">
    newLi=document. createElement(" li")
    newLi.onmouseov er=bulkVal( ' some string ',event)
    but i cant get it to work in FF1
    in IE6 it works but the event fires before the mouse is over the element, it fires once and that's it no more..

    i know that the event is passed implicitly to the handler so, if i change the word event to something like evt i get a message telling me that evt is not specified, if i ommit it it generates an error.
    if anybody can help , fast plz

    regards
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    Can i see more of the code please, and it will fire right off the bat because its not in a function and nothing is calling a function that i can see. although you didn't post all of the code.

    Comment

    • r_o
      New Member
      • Jul 2006
      • 35

      #3
      hey Clint,
      sure i'll 'reveal' as much code as you want haha..
      the eventHandler function takes 3 parameters : a string, the eventSource and the event itself.

      i tried to do it in IE6 as follows
      newLi.attachEve nt('onmouseover ',bulkVal(desc. replace("&#39;" ,"\&#39;"),this ,event) )

      and in FF1.5 :
      newLi.addEventL istener('mouseo ver',bulkVal(de sc.replace("&#3 9;","\&#39;"),t his,event),fals e )

      and still it does not work either ways!!

      i think the problem is with the ->event<- keyword because if i assign the function,same function, directly to an object it works as follows:

      < li onmouseover=" bulkVal(&#39; ' &#39;,&#39; \' &#39; , this, event)" >

      it works and fires only once just after the Li element is added to its parent and then
      nothing...

      appreciate your help

      Best Regards

      Comment

      • r_o
        New Member
        • Jul 2006
        • 35

        #4
        P.S :

        in the replace function i am using &#39 as '
        so don't get mixed up and think the code is wrong no

        Comment

        Working...