Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / June 2005



Tip: Looking for answers? Try searching our database.

Any way to read custom html attributes in firefox/opera ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andyjgw@gmail.com - 30 Jun 2005 16:59 GMT
Hi

Just a quick question - I guess this is more a 'standards' thing than
anything else.

I'm working on a digital mapping application. One of the things I'm
doing is outputting the IMG tag thus (just a sample):

< img id="myMap" src="somemap.gif" northing="1" easting="2" >

The reason I'm doing this is I'm looking to output some useful
information into the page from my asp.net source without resorting to
'tricks' like hidden input fields etc but still have them visible to
client-side JS.

In IE, I can read document.getElementById("myMap").northing, but when I
try this in Opera/Firefox these custom attributes aren't available.

Does anyone have any suggestions as to what I can do here?

Thanks in advance
AW
BootNic - 30 Jun 2005 17:26 GMT
> "andyjgw@gmail.com" <andyjgw@gmail.com> wrote:
> news:1120147190.531262.322170@o13g2000cwo.googlegroups.com....
[quoted text clipped - 21 lines]
> Thanks in advance
> AW

document.getElementById('myMap').getAttribute('northing')

Signature

BootNic     Thursday, June 30, 2005 12:25 PM

If we were not meant to make mistakes we would not have a Department of Corrections.
*Unknown**

Richard Cornford - 30 Jun 2005 17:30 GMT
<snip>
> <img id="myMap" src="somemap.gif" northing="1" easting="2" >
<snip>
> In IE, I can read document.getElementById("myMap").northing,
> but when I try this in Opera/Firefox these custom attributes
> aren't available.
>
> Does anyone have any suggestions as to what I can do here?

The most reliable approach to reading custom attributes is the -
getAttribute - method (with the assumption that the attribute name is
case sensitive, even though it officially doesn't need to be in HTML).

Richard.
AndrewW - 30 Jun 2005 18:11 GMT
Thanks guys, that's exactly what I was after :)

Never heard mention of a getAttribute method before, so.. cheers!

AW
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.