trying to replace/fix event.toElement

Discussion in 'Javascript' started by stanguru, Aug 22, 2006.

  1. stanguru

    stanguru Guest

    what is this statement doing?
    if (event.toElement && event.toElement.id.slice(0, 7) != "Options")
    and how can i replace with a cross-browser functionality? (manyly FF)

    its part of a menu, particularly a menuoff function

    i am trying to make the menu cross-browser ok, but i dont wanna rewrite
    the whole thing, i am figuring out 1 piece at a time

    i understand:
    it is IE specific and event is only an IE function
    the != is done first

    function MenuOff (z)
    {
    var Options;
    var Seq;
    var i;

    if (event.toElement && event.toElement.id.slice(0, 7) !=
    "Options")
    {
    // Get associated menu options (a <div>)
    Seq = z.getAttribute("Id").slice(4, 6);
    //Options = document.getElementById('Options') + Seq;
    Options = document.all["Options" + Seq];

    // Hide the menu options
    Options.getAttribute("Style").visibility = "hidden";
    }
    }

    TIA
     
    stanguru, Aug 22, 2006
    #1
    1. Advertisements

  2. *** escribió/wrote (22 Aug 2006 07:38:14 -0700):
    If I recall correctly, it's the source element of the event, that is, where
    the event generated.

    I normally use the addEvent function described here:

    http://dean.edwards.name/weblog/2005/10/add-event/
    http://dean.edwards.name/weblog/2005/10/add-event2/

    I guess the cross browser equivalent would be to assign an event:

    addEvent(my_element, 'click', my_function);

    And then use "this" inside my_function().
     
    Alvaro G. Vicario, Aug 22, 2006
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.