Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making javascript XHTML compatible

Status
Not open for further replies.

skwurl

Technical User
Sep 30, 2005
87
I have two pages.


The first one doesn't have any DOC types associated with it and the javascript menu works fine.

The second one has XHTML doc type

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"<html xmlns=" xml:lang="en" lang="en">

and the menu is scrambled. To be honest, I'm not even sure what Doc type I'm supposed to be using...I just assumed I should use this one.

What in the JS code is making it scrambled?
 
Broken it is - the URL doesn't exist!

That aside, you shouldn't let your JS dictate your DOCTYPE. Choose a DOCTYPE for the right reasons, and get your code working to it.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
At first glance, I would say that it's your CSS that is "breaking", not your JS, as the JS works, just displays differently.

However, I would expect this to be the case with different DOCTYPEs.

As I said before, choose a DOCTYPE that's right for you, then get your CSS and/or JS working to it.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
The current DOCtype is fine for my work. I'm still curious as to why the menu is showing up differently though.
 
From the link that Dan provided:
Unless you are going to be serving your documents as “text/xml” and loading them into an XML parser to allow your XML tools to manipulate the page, then there is no reason to develop your documents as XHTML. A majority of web pages on the internet are HTML - and this should be the default choice for developing your documents - especially if your web host is serving your pages as “text/html”.
I notice you are using XHTML Strict - and yet serving the content as text/html (when I tested in FireFox). So why are you using XHTML 1.0 Strict instead of HTML 4.01 Strict?

Seriously... I'll update the article if you can explain your reasoning! I wrote the article initially because I couldn't give a real reason for choosing XHTML over HTML - and I'd be keen to hear why you think using XHTML is better for you.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
I just read the documentation from my dropdown menu creator and it says that the menus only work in 'quirk mode'.

I think that means that it won't work with any doctype. What a pain in the ass.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top