Connecting Tech Pros Worldwide Help | Site Map

user-defined element properties: cross-browser?

  #1  
Old July 23rd, 2005, 06:33 PM
Timo
Guest
 
Posts: 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


  #2  
Old July 23rd, 2005, 06:33 PM
Dietmar Meier
Guest
 
Posts: n/a

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
  #3  
Old July 23rd, 2005, 06:33 PM
Martin Honnen
Guest
 
Posts: n/a

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/
  #4  
Old July 23rd, 2005, 06:33 PM
Timo
Guest
 
Posts: n/a

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]


  #5  
Old July 23rd, 2005, 06:33 PM
Timo
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
Hybrid container Rob McDonald answers 3 July 17th, 2008 06:25 PM
Databinding Marshalled Data From WebService Brad answers 6 November 18th, 2005 01:31 AM
XML Comment structure james autry answers 1 November 15th, 2005 10:04 PM
Future reuse of code James Cameron answers 253 November 13th, 2005 05:44 PM
Future reuse of code James Cameron answers 242 July 19th, 2005 05:48 PM