By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

user-defined element properties: cross-browser?

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Timo wrote:
Is there a counterpart functionality in Firefox, NS, and Opera


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

ciao, dhgm
Jul 23 '05 #2

P: n/a


Timo wrote:
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?


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/
Jul 23 '05 #3

P: n/a
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" <us***************@innoline-systemtechnik.de> wrote in
message news:36*************@individual.net...
Timo wrote:
Is there a counterpart functionality in Firefox, NS, and Opera


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

ciao, dhgm

Jul 23 '05 #4

P: n/a
Thank you, Martin.

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42*********************@newsread2.arcor-online.net...

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.
Martin Honnen

http://JavaScript.FAQTs.com/

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.