hi about creating listeners

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricardo Garcia

    hi about creating listeners

    hi, now i want to register a listener:
    if (document.addEv entListener)//IE6 does not support it
    x.addEventListe ner('click', method, false);
    else
    x.onclick = method;
    but my problem is that i want to pass some arguments along with the calling,
    how coult i do that??


    Another question, it is posible to distinguish between quirk and strict mode
    in the various browsers (opera, konqueror, mozilla, ie, mainly)


    Thanks


  • Michael Winter

    #2
    Re: hi about creating listeners

    On Tue, 2 Nov 2004 23:18:36 +0100, Ricardo Garcia <thrawnny@wanad oo.es>
    wrote:
    [color=blue]
    > hi, now i want to register a listener:
    > if (document.addEv entListener)//IE6 does not support it[/color]

    The better test is:

    if(x.addEventLi stener)

    That may only need to be performed once, but it would probably be more
    indicative than testing for document.addEve ntListener.
    [color=blue]
    > x.addEventListe ner('click', method, false);
    > else
    > x.onclick = method;
    > but my problem is that i want to pass some arguments along with the
    > calling, how coult i do that??[/color]

    You'll have to create a function to call that one. How exactly you do that
    depends on what you're passing.
    [color=blue]
    > Another question, it is posible to distinguish between quirk and strict
    > mode in the various browsers (opera, konqueror, mozilla, ie, mainly)[/color]

    To be honest, you shouldn't have to. All HTML should be written to invoke
    strict mode. However, you may be able to check that the
    document.compat Mode property contains the substring, "CSS".

    var mode = document.compat Mode;
    if(('string' == typeof mode) && (-1 != mode.indexOf('C SS'))) {
    // Strict rendering mode
    }

    This only works with IE 6, but I believe Mozilla and Opera also support it
    (not sure about Konqueror).

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: hi about creating listeners

      "Ricardo Garcia" <thrawnny@wanad oo.es> writes:
      [color=blue]
      > hi, now i want to register a listener:[/color]
      ....[color=blue]
      > x.addEventListe ner('click', method, false);[/color]
      ....[color=blue]
      > x.onclick = method;
      > but my problem is that i want to pass some arguments along with the calling,
      > how coult i do that??[/color]

      Don't call that function, but instead create a new one:

      var myMethod = function (event) {
      return method(event, someArgument, someOtherArgume nt);
      };
      ....
      x.addEventListe ner('click', myMethod, false);
      ....
      etc.

      [color=blue]
      > Another question, it is posible to distinguish between quirk and strict mode
      > in the various browsers (opera, konqueror, mozilla, ie, mainly)[/color]

      if (document.compa tMode == 'CSS1Compat') {
      // standards mode
      } else {
      // quirks mode
      }

      Should work in Opera, IE and Mozilla, don't know about Konq, but probably
      also that.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...