Marek: head und html-Tag in javascript schließen. w3c-validator meckert

Beitrag lesen

Folgendes Javascript befindet sich im head-Bereich einer HTML-Datei:

<script type="text/javascript">
<!--
  var ses = "en";
  if (navigator.browserLanguage) ses=navigator.browserLanguage;
  if (navigator.language) ses=navigator.language;
  if (document.cookie) {
    ses = document.cookie;
  } else {
    document.cookie = ses;
    if (ses=="de"){
      document.write("</head></html>");
    }
  }
//-->
</script>

Zunächst mal stelle ich keine Inkompatibilität mit aktuellen Browsern fest. Mein Problem ist also nicht die Funktion, sondern lediglich die standardkonforme Syntax, aber ich komm grad' nicht drauf, wie es richtig sein muß. W3C beschwert sich folgendermaßen:

#  Line 24, Column 29: end tag for "SCRIPT" omitted, but its declaration does not permit this

document.write("</head></html>");

* You forgot to close a tag, or
    * you used something inside this tag that was not allowed, and the validator is complaining that the tag should be closed before such content can be allowed.

The next message, "start tag was here" points to the particular instance of the tag in question); the positional indicator points to where the validator expected you to close the tag.

Info Line 14, Column 1: start tag was here

<script type="text/javascript">