[Jspro-devel] RE: Cross-browser compatibility
Brought to you by:
wigleys
From: Randolph T. F. <gat...@ci...> - 2003-09-03 04:49:15
|
Stuart - I am sure that this isn't the answer you were looking for, but both browsers are correct in their implementation of the DOM Level 1 Specification [http://www.w3.org/TR/2000/WD-DOM-Level-1-200 00929/level-one-core.html#ID-F68F082] (although Microsoft adds a proprietary third parameter that makes the comparison between the first parameter of the method and the actual HTML-element attribute name case-insensitive [http://msdn.microsoft.com/workshop/author/dh tml/reference/methods/setattribute.asp?frame=3D true]). The thing to remember when utilizing the setAttribute method is that the method--although a standard DOM method--is implementation dependent within the environment the method is running in. Therefore, in IE, the method is dependent on the JScript implementation of the DOM and DHTML, and in Mozilla, the method is dependent on the JavaScript implementation of the DOM and DHTML. Unfortunately, Microsoft's JScript implements the "class" attribute in the DOM and DHTML as the property "className". Likewise, JScript implements the "colspan" attribute as the property "colSpan". Why Microsoft did this is beyond me, but that is just the way it is in JScript. Therefore, the setAttribute method in IE has to respect these property names to function correctly, and you will need to have browser-specific forks in jsPro if you plan on using these attributes. Personally, the way the Mozilla team implemented the DHTML functionality is the way it should be, since the DHTML property names match up identically with the HTML-element attribute names, but we sure can't do anything about changing JScript. This won't be the last time we run into this sort of thing! :-) Cheers, Randy -----Original Message----- From: jsp...@li... [mailto:jsp...@li...urceforge.n et] On Behalf Of Stuart Wigley Sent: Tuesday, September 02, 2003 5:59 AM To: jsp...@li... Subject: [Jspro-devel] Cross-browser compatibility Hi, I've got two problems with the use of HTMLElement.setAttribute() that i'd like to discuss in terms of cross-browser compatibility. I (kind of) understand why IE and Mozilla are different in the following examples but I'm not really sure which browser is 'correct'. myTableCell.setAttribute('colspan', 2) - Mozilla, not IE myTableCell.setAttribute('colSpan', 2) - IE, not Mozilla myTableCell.setAttribute('class', 'foo') - Mozilla, not IE myTableCell.setAttribute('className', 'foo') - IE, not Mozilla I've found myself wanting to use these examples in jsPro to implement a new Debug class for handling custom debug messages and the redirection of Error messages. Lets make this our first Mailing List discussion :-) Cheers Stuart _____________________________________________ ___________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/ |