Monday, July 10, 2006

Browsers: Compatibility

This will work in some browsers like IE. elementName is from form object's name.
formName.elementName

For compatibility, use form object's id
document.getElementById('elementID')

Another issue is using comments
<!-- comment -->

This is okay in MS IE but not in Mozilla Firefox. So avoid using this style of comment. Use only two hyphens/dashes.
<!------------ comment ----------->

(Thanks to Cacho for this)

Manipulating style attribute's display using javascript, use '' instead of 'block' or other values aside from 'none' to go back to it's default value. This is useful when showing/hiding object. Other common values are 'table-row' and 'inline'.
object.style.display = 'none';
object.style.display = ''; // restores default value.

IME Mode (Internationalization format) is an IE specific attribute in CSS.

No comments: