Page 1 of 1

Page won't validate because of document.write()

Posted: Thu Nov 30, 2006 12:14 pm
by Luke
Since I want my site to work with javascript on or off, I have done something like this...

Code: Select all

        <script type="text/javascript">
         <!--
          document.write ('<a href="javascript:;" onclick="new Effect.Appear(\'review_form\', { duration: 0.8 });">Review this product</a>');
         //-->
        </script>
        <noscript>
          <a href="reviews.php">Review this product</a>
        </noscript>
But the document.write() portion causes my page not to validate...
Error Line 173 column 137: end tag for element "A" which is not open.

...tion: 0.8 });">Review this product</a>');
Is there some way I can get the validator to know that the html inside of the quotes isn't html (yet)?

Is there anything I can do? Thanks fellas!

Posted: Thu Nov 30, 2006 11:12 pm
by feyd
Use the DOM to generate the link?

Posted: Thu Nov 30, 2006 11:22 pm
by nickvd
Agreed, doc.write is oollddd and icky...

I see that you're using scriptaculous, i believe that prototype has it's own dom creation methods, it's been a while since i've used it (switched to jquery and Interface) so I won't be much help :)