Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:17
Menu Bug: XHTML compliance (Replace document.write)
Poster: luegner
Dated: Thursday January 19 2006 - 19:26:33 GMT
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
Poster: John
Dated: Monday January 23 2006 - 14:01:53 GMT
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?
Poster: Ruth
Dated: Monday January 23 2006 - 14:14:52 GMT
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:
<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>
<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
Poster: luegner
Dated: Monday January 23 2006 - 16:55:48 GMT
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?
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.
Poster: Ruth
Dated: Monday January 23 2006 - 18:00:55 GMT
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
Poster: John
Dated: Monday January 23 2006 - 21:51:01 GMT
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.
Poster: luegner
Dated: Tuesday January 24 2006 - 21:46:24 GMT
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.
Poster: Andy
Dated: Monday April 10 2006 - 15:50:36 BST
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
Poster: GeorgeIII
Dated: Tuesday April 25 2006 - 17:50:28 BST
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.
...
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?
Poster: Andy
Dated: Thursday June 8 2006 - 11:03:49 BST
Quote:
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]