W3C home > Mailing lists > Public > www-validator@w3.org > October 1999

document.write causes validation to fail

From: <pdf@bizfon.com>
Date: Thu, 14 Oct 1999 10:06:08 -0400
To: www-validator@w3.org
Message-ID: <8525680A.004BC798.00@Enterprise>

I've seen similar posts on this, but I haven't found a conformation that
this is a bug in the validator.  I'm working on a page that has a bunch of
Javascript and one of the functions includes this:

     HelpWindow =
window.open('','helpWin','width=200,height=150,left='+(screen.width-225)+',
top=95,toolbar=no,location=no');
     HelpWindow.focus();

HelpWindow.document.write("<HTML>\n<HEAD><TITLE>Description</TITLE></HEAD>\
n<BODY BGCOLOR='WHITE'>\n<P><B>");

     HelpWindowState = "test";

     HelpWindow.document.write(HelpWindowState);
     HelpWindow.document.write("</B>\n</BODY>\n</HTML>");
     HelpWindow.document.close();

For some reason, the validation doesn't seem to realize that this HTML code
 is being generated, because it complains about the stuff inside the
document.write parenthesis.
This seems like a bug with the validator.  Am I wrong?  This code works,
but because of this error, I can't tell if the rest of my document would
pass the validation (it thinks that the HTML elements in the document.write
parenthesis are for the document I'm working on, which throws the rest of
them out of whack... at least for the validator).  I'm using:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



Here's the complete list of errors:

Error at line 84:
   L>\n<HEAD><TITLE>Description</TITLE></HEAD>\n<BODY BGCOLOR='
                                              end tag for element "TITLE"
                                        which is not open (explanation...)
---------------------------------------------------------------------------
-----

Error at line 84:
   te("<HTML>\n<HEAD><TITLE>Description</TITLE></HEAD>\n<BODY BGCOLOR='WH
                                                             end tag for
"SCRIPT" omitted,
          but its declaration does not permit this (explanation...)
---------------------------------------------------------------------------
-----

Error at line 21:
   <script language="JavaScript" type="text/javascript">
    start tag was here
---------------------------------------------------------------------------
-----

Error at line 84:
   >Description</TITLE></HEAD>\n<BODY BGCOLOR='WHITE'>\n<P><B>");
           document type does not allow element "BODY" here
---------------------------------------------------------------------------
-----

Error at line 102:
     HelpWindow.document.write("</B>\n</BODY>\n</HTML>");
                 character data is not allowed here
---------------------------------------------------------------------------
-----

Error at line 184:
   </script>
           end tag for element "SCRIPT" which is not open (explanation...)
---------------------------------------------------------------------------
-----

Error at line 186:
   </HEAD>
         end tag for element "HEAD" which is not open (explanation...)
---------------------------------------------------------------------------
-----

Error at line 188:
   <BODY onload="Javascript:onPageLoad();">
                                          document type
                              does not allow element "BODY" here
---------------------------------------------------------------------------
-----

Error at line 305:
   </HTML>
         end tag for element "HTML" which is not open (explanation...)
Received on Thursday, 14 October 1999 10:04:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:13:52 GMT