[thelist] [tip] Mac IE doctype/dynamic styles
Erik Mattheis
gozz at gozz.com
Sat Mar 23 19:31:01 CST 2002
This started out as a frustrated question, but turned into a tip:
<tip type="Mac IE 5 doctype and dynamic styles" author="Erik Mattheis">
Mac IE is picky about dynamically set styles when you use a strict or
any XHTML doctype declaration.
With the doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"> (or no doctype), you can set styles using a number
or string with or without units specified:
document.getElementById('id').style.height = 72;
document.getElementById('id').style.height = '72';
document.getElementById('id').style.height = '72px';
And you can set colors with or without the pound sign:
document.getElementById('id').style.backgroundColor = 'ffffff';
document.getElementById('id').style.backgroundColor = '#ffffff';
All work fine.
But with a strict HTML 4 or any XHTML doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
You have to set the value of styles as strings with units specified:
document.getElementById('id').style.height = '72px';
And must use the pound sign for colors:
document.getElementById('id').style.backgroundColor = '#ffffff';
Not doing so results in an "Invalid procedure call or argument" error.
</tip>
--
__________________________________________
- Erik Mattheis
(612) 377 2272
http://goZz.com/
__________________________________________
More information about the thelist
mailing list