473,473 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

custom attributes in firefox

I am building custom attributes as a means to pass data from the client
to the server. To accomplish this task, a class of "postback" is
applied to a link or button. When the link or button is clicked,
custom attributes are parsed from the link and submitted to the
application as hidden form fields. The code below better illustrates
the HTML:

<a class="postback" c:myAttribute1="value"
c:myAttribute2="value">submit</a>

This works fine in IE (6 and 7), however the JavaScript engine in
FireFox treats attributes as case-insensitive and, as a result, submits
the hidden input as "myattribute1" and "myattribute2". The server code
is case-sensitive, so it does not get the proper value. I was
wondering if there were any ways to mitigate this problem on the
client. I understand that there are many server-side solutions.
Additionally, I understand that the w3c recommends that attributes
should be case-sensitive. However, I have a need to make this work.

Sep 19 '06 #1
3 6442
VK

mr****@gmail.com wrote:
This works fine in IE (6 and 7), however the JavaScript engine in
FireFox treats attributes as case-insensitive and, as a result, submits
the hidden input as "myattribute1" and "myattribute2".
HTML is case-insensitive, so are its tag names and attribute names (but
not attribute values). In this respect <a FOO="bar">, <a Foo="bar"or
<a foo="bar"is all the same for all browsers. But for the internal
representation (say for DOM Inspector display) UA "normalize" attribute
names by bringing them to one case. IE "normalize" to upper case, FF
"normalize" to lower case, and someone maybe normalize it to
camel-case, I donno :-)
DOM methods hasAttribute, getAttribute, setAttribute in IE have
additional argument to switch the "normalization" off/on, but you check
on mozilla.org if they have this extension (possibly not).
The server code
is case-sensitive, so it does not get the proper value.
As you cannot predict the "normalization" results for UA, do
normalization yourselve cerver-side before process data (say everything
to upper case). That seems as the easiest solution. I presume you don't
have any burning necessity to have different attributes differing by
their case only like Foo and FOO ;-)

Sep 19 '06 #2


mr****@gmail.com wrote:

The code below better illustrates
the HTML:

<a class="postback" c:myAttribute1="value"
c:myAttribute2="value">submit</a>
Does that validate as HTML 4? Or as XHTML 1?
This works fine in IE (6 and 7), however the JavaScript engine in
FireFox treats attributes as case-insensitive and, as a result, submits
the hidden input as "myattribute1" and "myattribute2".
The JavaScript engine? That implements stuff like numbers, boolean,
strings, Date but does not implement any host objects like HTML element
objects.
What JavaScript code are you using exactly, to at least give us a chance
to try to understand what you do?

Additionally, I understand that the w3c recommends that attributes
should be case-sensitive. However, I have a need to make this work.
Well you could serve XML to Firefox, then I am sure it follows the rules
of XML and case-sensitivity:
<http://home.arcor.de/martin.honnen/javascript/2006/09/test2006091901.xhtml>
Despite your beliefs of what the JavaScript engine does.

If you let stuff parse by an HTML/SGML parser then expect some case
folding or case normalization to be done, for instance the SGML parser
the W3C validator uses normalizes attribute names to all upper case, see
the parse tree in
<http://validator.w3.org/check?uri=http%3A%2F%2Fhome.arcor.de%2Fmartin.honn en%2Fjavascript%2F2006%2F09%2Ftest2006091901.html& charset=%28detect+automatically%29&doctype=Inline& sp=1&verbose=1>

And what does it help if you adapt your code for (some version of)
Firefox? Another browser might do something different with its tag soup
parser. Custom attributes in HTML are not really reliable, and if you
even want case-sensitivity then you have choosen the wrong approach for
that validation feature you want.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 19 '06 #3
Thanks. I am serving HTML 4.01. I do not think it validates. Martin,
I learned a lot from your examples.

The following would be a good representation:

function listAttributes (element) {
for (var i = 0, l = element.attributes.length; i < l; i++) {
alert('name=' + element.attributes[i].name);
}
}

I am resigned to the fact that Firefox will normalize these attributes
per this doctype.

For what browsers would you not expect custom attributes to work?

Sep 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: ...
3
by: andyjgw | last post by:
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...
8
by: nicolas.sanguinetti | last post by:
Hi, I want to add custom attributes to my xhtml documents to use with my DOM scripts. For example, I want to have some tags -say, the <h1>- have an attribute and a . The thing is that I also...
3
by: Edward Diener | last post by:
I understand the syntax of custom attributes, but I have no idea what they are supposed to do. Anyone care to give me a clue as to their functionality ?
1
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI...
9
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a...
3
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
1
by: cardalda | last post by:
Hi all, When I add custom attributes to a TextBox, I can read them out in javascript under IE6. For example: in C# TextBox1.Attributes.Add("MyString", "ABC");...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.