Connecting Tech Pros Worldwide Help | Site Map

user-defined element properties: cross-browser?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:33 PM
Timo
Guest
 
Posts: n/a
Default user-defined element properties: cross-browser?

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, 05:33 PM
Dietmar Meier
Guest
 
Posts: n/a
Default 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, 05:33 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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, 05:33 PM
Timo
Guest
 
Posts: n/a
Default 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, 05:33 PM
Timo
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.