View Full Version : Why does Javascript/DHTML Ignore CSS styles??
Fukui
May 28, 2005, 01:48 AM
This is reaaly annoying, ,but I'm trying to implement scrolling behavior in a web app and I'm getting that object.style.left etc always returns "Undefined," even when set in CSS file!
Ok, if I set the left or top property inline such as, "style=left:2; top:4" it works and object.style.left properly returns 2px, but if set in an external CSS it doesnt work.
Any clue to why this is??
FattyMembrane
May 28, 2005, 07:52 PM
i have the same problem and haven't been able to figure it out. i'd be very thankful if someone has an answer or solution.
Fukui
May 28, 2005, 11:40 PM
i have the same problem and haven't been able to figure it out. i'd be very thankful if someone has an answer or solution.
Seems like nobody knows...
I'll check the apple mailing lists, if I get any response I'll post it here...
Rower_CPU
May 29, 2005, 04:49 PM
As a workaround you could just use descendancy and use the element type in your stylesheet for the object the js is working on.
For instance, if the scrolling text is in a <div>, add a container <div> with an id on it and set the style for "#id div" in your stylesheet.
Fukui
May 30, 2005, 05:31 AM
As a workaround you could just use descendancy and use the element type in your stylesheet for the object the js is working on.
For instance, if the scrolling text is in a <div>, add a container <div> with an id on it and set the style for "#id div" in your stylesheet.
Yea, I've done that, but was hoping there could be another solution... is this behavior W3C or what? IE, FF and Safari all exhibit this...
Fukui
Jun 1, 2005, 03:18 AM
Ok Guys here it is.
http://www.oreillynet.com/pub/a/javascript/excerpt/JSDHTMLCkbk_chap5/index5.html
Enjoy.
Rower_CPU
Jun 1, 2005, 10:07 PM
That's no fun.
Seems like another argument for separation of content (HTML), presentation (CSS), and behavior (JS) to me.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.