Menu Bug: XHTML compliance (Replace document.write)

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
luegner
Advanced
Advanced
Posts: 21
Joined: Fri Dec 12, 2003 6:49 pm

Menu Bug: XHTML compliance (Replace document.write)

Post by luegner »

The use of document.write in the menu should be replaced with DOM calls. This is a problem when building XHTML pages on a server that serves the correct xhtml mimetype: application/xhtml+xml

The problem is documented here:

http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

It works (otherwise the menu wouldn't for those of us who write XHTML), it just doesn't validate.
luegner wrote:The problem is documented here:
Mentioned, but not 'documented'. Got a better link?
John
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Are you talking about the calls for the menu? I have checked the one site I know has xhtml and it validates, the calls for the menu are

Code: Select all

<script src="/template/main/milonic_src.js" type="text/javascript"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
if(ns4)_d.write("<scr"+"ipt language='JavaScript' src='/template/main/mmenuns4.js'><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language='JavaScript' src='/template/main/mmenudom.js'><\/scr"+"ipt>");
//--><!]]>
</script>
<script src="/template/main/xtopmenu.js" type="text/javascript"></script>
and when I check the site for validation those calls do not show as any error.

Ruth
luegner
Advanced
Advanced
Posts: 21
Joined: Fri Dec 12, 2003 6:49 pm

Post by luegner »

John wrote:It works (otherwise the menu wouldn't for those of us who write XHTML), it just doesn't validate.

Mentioned, but not 'documented'. Got a better link?
What? You should really read up on the XHTML spec. The problem with the menu can be demonstrated pretty easily. Add this to the top of your document if you're using PHP and you'll know what I'm talking about (Don't attempt this on M$IE, do it on FF):

header("Content-Type: application/xhtml+xml; charset=UTF-8");

More Links:

http://www.w3.org/TR/xhtml-media-types/#text-html
http://en.wikipedia.org/wiki/XHTML
http://www.mozilla.org/docs/web-developer/faq.html

Ruth wrote:and when I check the site for validation those calls do not show as any error.
Yes, it validates but if it is served as actual XHTML with the _true_ mimetype, it won't render with document.write.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I thought the whole purpose of the cdata tags was that the parser ignored everything in the tags.

But, this is not something I do and I don't know much about xhtml.

Ruth
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

1. I don't write PHP.

2. I write XHTML, with a valid doctype, and the menu works for me.

3. My apologies for not knowing as much as you apparently do.
John
luegner
Advanced
Advanced
Posts: 21
Joined: Fri Dec 12, 2003 6:49 pm

Post by luegner »

John wrote:2. I write XHTML, with a valid doctype, and the menu works for me.
Writing a document with the XHTML doctype is only part of the equation. A true XHTML document is served like an XML document with application/xhtml+xml because it is an XML document. Now if you're writing plain html pages, then it depends on the server (Apache, IIS) configuration as to whether or not it's serving html documents as text/html or application/xhtml+xml. If the server serves the document as application/xhtml+xml, the XML parser will take over on Gecko (Firefox, Mozilla, Seamonkey, Epiphany, Camino, etc), instead of using the tag soup parser. When that happens, document.write will no longer work and neither will innerHTML for that matter and the result is that the milonic menu will not display because it makes use of document.write. document.write for that matter isn't even a DOM method anyway.
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

That is correct, the menu uses document.write which is not compatible with XHTML

However, I have yet to see any serious benefit of using XHTML and therefore cannot at this point in time see a valid reason for re-writting the menu.

Also, if we do opt for XHTML compliance, this will mean that the menu is no longer classed as cross browser because it will only work with the latest browser versions.

Kind Regards
Milonic Support
GeorgeIII
Beginner
Beginner
Posts: 1
Joined: Tue Apr 25, 2006 5:43 pm

Post by GeorgeIII »

Andy wrote:That is correct, the menu uses document.write which is not compatible with XHTML

However, I have yet to see any serious benefit of using XHTML and therefore cannot at this point in time see a valid reason for re-writting the menu.

...
Regardless of XHTML, document.write() means it is not possible to use Milonic DHTML Menus in conjunction with client-side XSLT with Mozilla :(

http://www.mozilla.org/projects/xslt/faq.html

4. What about document.write?

Just like for XHTML, document.write is not supported during XSLT
transformations.

Do Milonic have a menu version which does not use document.write()?
Why not just update using DOM interface or innerHTML?
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Why not just update using DOM interface or innerHTML?
It's because it is not cross browser compatible.

This will fail in older browsers. believe it or not, people still want support for Netscape 4 and using this means the menu will break in the browser and also break in older versions of Internet Explorer[/quote]
Post Reply