user-defined element properties: cross-browser?

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

    #1

    user-defined element properties: cross-browser?

    I've noticed that this is possible in IE:

    <span class='sweetfea ture' myproperty='Nap oleon Dynamite'
    onclick="ShowPr operty(this);" >
    Click here for the name of a hilarious movie.
    </span>

    and then in a script:

    function ShowProperty(e) {
    alert(e.myprope rty);
    // or
    // alert(e['myproperty']);
    }

    Is there a counterpart functionality in Firefox, NS, and Opera, or is this a
    proprietary MSFT feature that the other browser vendors do not support?
    Thanks
    TR


  • Dietmar Meier

    #2
    Re: user-defined element properties: cross-browser?

    Timo wrote:
    [color=blue]
    > Is there a counterpart functionality in Firefox, NS, and Opera[/color]

    Depends on the doctype you use. What you showed is not valid HTML.

    ciao, dhgm

    Comment

    • Martin Honnen

      #3
      Re: user-defined element properties: cross-browser?



      Timo wrote:
      [color=blue]
      > I've noticed that this is possible in IE:
      >
      > <span class='sweetfea ture' myproperty='Nap oleon Dynamite'
      > onclick="ShowPr operty(this);" >
      > Click here for the name of a hilarious movie.
      > </span>
      >
      > and then in a script:
      >
      > function ShowProperty(e) {
      > alert(e.myprope rty);
      > // or
      > // alert(e['myproperty']);
      > }
      >
      > Is there a counterpart functionality in Firefox, NS, and Opera, or is this a
      > proprietary MSFT feature that the other browser vendors do not support?[/color]

      The core DOM offers the getAttribute method for element objects so
      if (e.getAttribute ) {
      alert(e.getAttr ibute('myproper ty'));
      }
      is probably what you are looking for.


      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Timo

        #4
        Re: user-defined element properties: cross-browser?

        Thanks for the reply, Dietmar. Do I understand you correctly, that it would
        be possible to achieve this user-defined property functionality
        cross-browser, simply by declaring the appropriate doctype?
        TR

        "Dietmar Meier" <usereplytoinst ead@innoline-systemtechnik.d e> wrote in
        message news:36ekn4F4v2 hkmU1@individua l.net...[color=blue]
        > Timo wrote:
        >[color=green]
        > > Is there a counterpart functionality in Firefox, NS, and Opera[/color]
        >
        > Depends on the doctype you use. What you showed is not valid HTML.
        >
        > ciao, dhgm[/color]


        Comment

        • Timo

          #5
          Re: user-defined element properties: cross-browser?

          Thank you, Martin.

          "Martin Honnen" <mahotrash@yaho o.de> wrote in message
          news:42021fb2$0 $820$9b4e6d93@n ewsread2.arcor-online.net...[color=blue]
          >
          > that the other browser vendors do not support?
          >
          > The core DOM offers the getAttribute method for element objects so
          > if (e.getAttribute ) {
          > alert(e.getAttr ibute('myproper ty'));
          > }
          > is probably what you are looking for.
          >[color=green]
          > > Martin Honnen[/color]
          > http://JavaScript.FAQTs.com/[/color]


          Comment

          Working...