PDA

View Full Version : Can Javascript affect the css divs?



kuau
07-27-2008, 08:52 PM
1) Script Title: Jason's Date Input Calendar

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

3) Describe problem: The calendar works great and everything. I'm just wondering if javascript can screw up css? Is there a way to encapsulate the javascript so that it behaves within my divs? I checked the js code and didn't find any </div>'s, but nevertheless it forces anything beside the mini-cal image on the right side of the calendar down to the next line even though I have { display:inline; } . It also somehow "leaks" into the div below in FF.

Here's my css for the little div that holds the date field:


#enddate { width:740px; height:42px; float:left; margin-top:7px; display:inline; }

I've used other DD js scripts and did not have this problem. I can't find any errors in my css for the surrounding divs (but I'm pretty bleary right about now).

Thanks for any insight. :)

jscheuer1
07-28-2008, 10:43 AM
I'd like to see the page. However, this sounds like a case where something which ordinarily should be absolutely positioned, either is, and is being added to a relatively or absolutely positioned container instead of to the body element itself, or that it isn't absolutely positioned. If it is either of these two cases, more likely the second, it can 'push' other things in the layout around.

More broadly, javascript can affect just about anything in a document's content or style. Generally this is intentional and gracefully executed, though unexpected results can happen when the code isn't well thought out, and/or is applied to a page in a way that is different than originally intended by the code's author.

kuau
07-28-2008, 03:35 PM
Thanks, John. I fixed it. I just had to put the javascript in its own div within the enddate div. I was just over-tired and couldn't think straight. Appreciate your help.