Re: Valid positioning of script elements

Hi,
My name is actually Peter Foti (I copied Andrew Clover's original message into
mine).
I realize that the method you show below is valid.  But what I want to know is
why is the other method invalid?  It's much easier to write:

<table>
     <tr>

than it is to write:

<script type="text/javascript">
   document.write('<table>');
   document.write('<tr>');
...

For one thing, it takes up less space, and smaller files are always a good
thing.  But it also makes it easier to debug if something goes wrong.  Perhaps I
have a giant table with only 1 item that needs to be printed with scripting
(some dynamic piece of data).  It's not convenient to write out the whole table
in a giant script.  Thanks for the input, but I still don't have an answer as to
WHY this is invalid.
Thanks,
Pete






"Bertilo Wennergren" <bertilow@hem.passagen.se> on 06/05/2000 05:59:09 PM

To:   Peter Foti@pctco.com, www-validator@w3.org
cc:

Subject:  Re: Valid positioning of script elements



Andrew Clover:

> The following code is invalid, according to the w3 validator.  But I would
argue
> that it should not be.  Can someone offer an explanation as to why it should
be
> invalid?

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
>      <title>Test</title>
> </head>
>
> <body>
>
> <table>
>      <tr>
>           <td>1,1</td></tr>
>      <script language="Javascript" type="text/javascript">
>      var str = "<tr><td>2,1<\/td><\/tr>"
>      document.write(str);
>      </script>
> </table>
>
> </body>
> </html>

Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
     <title>Test</title>
</head>

<body>

<script type="text/javascript">
   document.write('<table>');
   document.write('<tr>');
   document.write('<td>1,1<\/td><\/tr>');
   var str = "<tr><td>2,1<\/td><\/tr>";
   document.write(str);
   document.write('<\/table>');
</script>

</body>
</html>

#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                     <bertilow@hem.passagen.se>
#####################################################################

Received on Monday, 5 June 2000 18:10:48 UTC