View Full Version : Doctype Breaks Menu

10-16-2008, 02:28 AM
I'm sorta undecided to post here or in the ajax or even php forums. I'm looking to create a nice slide in menu that will get its links (likely both headers and actual links) from a database. I hope to eventually use the menu in conjunction with vbulletin forums.

If something similar already exists, I would be very interested in seeing a demo of some kind.

So in doing some searches, I did find this nice javascript menu to start working on modifying.


Now, on some local testing, the menu will slide nicely in and off the page. But the minute I add a doctype to the page, the menu stops working. As I'm pretty clueless with javascript, would anyone know why that would occur?

10-16-2008, 11:32 AM
Tables are really bad for layout! (http://www.hotdesign.com/seybold/)
You should have a valid DOCTYPE (http://www.alistapart.com/stories/doctype/)before all documents.
After all, your document must be a valid one (http://validator.w3.org/).

10-16-2008, 03:46 PM
Thanks for the help/tip, and while I agree that tables are not the best of approaches, I'm working with what I have at the moment. I didn't create the slide in menu, but am going to try and modify it fit my needs.

And yes, a DocType should be on each and every page. And like my initial question. When I add any doctype to the beginning of the page, the menu will stop working, no longer sliding in an off the page correctly.

So why would adding a doctype cause the javascript to stop working? Are you trying to say that the use of tables is actually breaking the menu when adding a DocType?

10-16-2008, 04:51 PM
When there is no DOCTYPE, the borwser renders the page in quirks mode, and you may get some result, which may be proper or improper, depending on the browsers rendering engine.

But, when there is avalid DOCTYPE, the browser would turn in to standard mode and the rendering will be based on that DOCTYPE. Thus, you'll get a uniform display across browsers. But, you need to provide a valid set of tags now. So add a proper DOcTYPE and then validate your code and fix the errors in your markup.

10-16-2008, 06:25 PM
it works for me in IE
with doc type

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

The script is old and does not work in Moz browsers

needs a complete rework

10-16-2008, 07:04 PM
BUT, The script is old and does not work in Moz browsers

needs a complete rework

And who in their right mind would use IE these days anyway? :) I use Moz and Opera almost exclusively.

Maybe I'll try and rework it, but JS is definitely not my strong suit.

Again, I would really like something similar that is done with php and ajax to work with a database for its links. But until I find something like that, I'm stuck trying to modify this one.