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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

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

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Use the DOM to generate the link?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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 :)
Post Reply