[thelist] RE: Moving a <div> with javascript
Robert Vreeland
vreeland at studioframework.com
Tue Mar 11 15:46:48 CST 2003
Hello list,
This might be better as a tip, but it is on topic here.
I have noticed a lot of code lately that manipulates the ccs attributes. There is something that we tend to forget ( I spent all yesterday tracking this bug down in my own code), you can apply a stylesheet in 4 ways: inline, embedded , linked or through a script (typically JavaScript). When you apply a stylesheet by creating it through a script (which is what happens when you manipulate the style attribute without it being specifically applied in a css stylesheet) expect quirky behavior when you attempt to manipulate it again. Huh?
Here is my example,
I have a input box that I changed the border color to red if the data did not validate.
layerRef = eval(doc + errField + forstyle);//'errField' is the passed in id input field that failed to validate
layerRef.borderColor = "red"; // just created the style attribute borderColor
the input box looked like this:
<input type="text" name="thislname_y_lname" id="thislname_y_lname" >
the border would turn red every time , no problem.
so I went nuts when after the from was revalidated and I tried to change the border back to gray, IE would tell me that there was no such property. After I changed the input box to:
<input type="text" name="thislname_y_lname" id="thislname_y_lname" style="border-color: gray;">
I had no more problems( at least with that part of the script)
so I would recommend playing it safe, any css element that you want to manipulate through scripting make sure you set it in a stylesheet. As with this thread. set the left properties in a stylesheet #someid {position: absolute; left: 0px ;}
Hope this helps
Robert
vreeland at studioframework.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/thelist/attachments/20030311/e79f4774/attachment.htm>
More information about the thelist
mailing list