[thelist] Javascript newbie - errors

Kristof Neirynck k.neirynck at belgacom.net
Sat Oct 25 19:16:24 CDT 2003


Tim Burgan wrote:
> 
> [1] <http://www.greaterthani.com/05_programming/week2.htm>
[snip]

Your page has a XHTML 1.1 doctype and it validates.
Congratulations, tap yourself on the back and take a cookie.


The rest of my comment is much less flattering, sorry.

You send your XHTML 1.1 page with the "text/html" mimetype.
That is considered harmful.
<http://www.hixie.ch/advocacy/xhtml>

To fix this you have three options:
1. Send your page as "application/xhtml+xml" to all browsers.
Internet explorer will no longer open your page.

2. Send your page as "application/xhtml+xml" for the browsers that 
support it.
<http://www.webstandards.org/learn/askw3c/sep2003.html>

2a) This will break your javascript
document.write() does not work in Gecko-based browsers.
Solution: you'll need the learn the DOM-way of doing this.
<http://www.xs4all.nl/~ppk/js/index.html?/~ppk/js/dom1.html>

2b) This will make your css (and inline javascript)  invisible
You put your css between comment tags.
<style type="text/css" media="all">
<!--
THIS IS COMMENT.
IT WILL BE IGNORED.
-->
</style>
<script type="text/javascript">
<!--
THIS IS COMMENT.
NOTHING HERE.
-->
</script>
Solution: put your css in an external file and get rid of the comment 
tags in your inline javascript or get rid of the inline javascript.

3. Change your doctype to XHTML 1.0 and keep sending it as text/html.
You still should consider fixing your css and inline javascript, but 
that should not be a problem.



Kristof





More information about the thelist mailing list