View Full Version : Javscript Menu and CSS

01-22-2005, 12:09 AM
This line of code:

<link href="[path to css file here]" type="text/css" rel="stylesheet">

is causing a JS/DHTML nav menu to load incorrectly. The menu is about 3 times as wide as I specified in my config file, and the background colors are all white.

I was wondering if anyone knew why the CSS link is throwing off my code.


Dan Barr

01-22-2005, 12:42 AM
Well If you could show an actual example of this it would be very helpful because if used correctly that line of code should cause no problems. The style sheet that is linking to or improper use of that tag could cause a problem like this. The tag itself should be in the head of the document (<head> </head>) and should be before the body tag etc etc. Anyways an example is needed.

One note, this thread really should be in html/css forum as this has nothing to do with javascript but rather html/css.

01-22-2005, 01:01 AM
Sorry. I was still working on the example.

Here it is:


Now when I put it on the web, it has JS Error, 'menus' are undefined


This should probably go in dynamic drive area, as this is a DD script...

01-22-2005, 10:52 AM
There are no Javascript ERRORS in this example.

The link to the external "main.css" is just screwing up the layout since the content of "main.css" overrides the definition of all the table/tr/td TAGS in the HTML, including the Javascript dynamically generated menu which are tables/tr/td themselves.

If you change the first "table" in "main.css" to be ".mytable" and then assign the class ".mytable" to the table in your HTML this will make you understand better what I mean.

Use class names in your HTML and CSS files instead of referring to global TAGS. For more info visit the CSS/HTML forum.