Connecting Tech Pros Worldwide Forums | Help | Site Map

user-defined element properties: cross-browser?

Timo
Guest
 
Posts: n/a
#1: Jul 23 '05
I've noticed that this is possible in IE:

<span class='sweetfeature' myproperty='Napoleon Dynamite'
onclick="ShowProperty(this);" >
Click here for the name of a hilarious movie.
</span>

and then in a script:

function ShowProperty(e) {
alert(e.myproperty);
// 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
Guest
 
Posts: n/a
#2: Jul 23 '05

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
Martin Honnen
Guest
 
Posts: n/a
#3: Jul 23 '05

re: user-defined element properties: cross-browser?




Timo wrote:
[color=blue]
> I've noticed that this is possible in IE:
>
> <span class='sweetfeature' myproperty='Napoleon Dynamite'
> onclick="ShowProperty(this);" >
> Click here for the name of a hilarious movie.
> </span>
>
> and then in a script:
>
> function ShowProperty(e) {
> alert(e.myproperty);
> // 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.getAttribute('myproperty'));
}
is probably what you are looking for.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Timo
Guest
 
Posts: n/a
#4: Jul 23 '05

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" <usereplytoinstead@innoline-systemtechnik.de> wrote in
message news:36ekn4F4v2hkmU1@individual.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]


Timo
Guest
 
Posts: n/a
#5: Jul 23 '05

re: user-defined element properties: cross-browser?


Thank you, Martin.

"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:42021fb2$0$820$9b4e6d93@newsread2.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.getAttribute('myproperty'));
> }
> is probably what you are looking for.
>[color=green]
> > Martin Honnen[/color]
> http://JavaScript.FAQTs.com/[/color]


Closed Thread


Similar JavaScript / Ajax / DHTML bytes