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

A

andyjgw

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
 
B

BootNic

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

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

Richard Cornford

<img id="myMap" src="somemap.gif" northing="1" easting="2" >
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.
 
A

AndrewW

Thanks guys, that's exactly what I was after :)

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

AW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top