Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No, why is THIS not valid

    xhtml10 strict:

    <script type="text/javascript">
    document.write('<a style="color:white" href="'+'mailto:'+'cg9com'+'@'+'juno.com'+'">'+'cg9com'+'@'+'juno.com'+'</a>');
    </script>

  2. #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unless i'm much mistaken, inline javascript is not permitted in XHTML. If you put that code in an external .js file, it should validate fine.

  3. #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's no explicit restriction on using inline scripts with XHTML, but any occurance of "<" or ">" in the script code will cause a problem.

    To get around that you can use a CDATA section:

    Code:
    <script type="text/javascript">// <![CDATA[
    
     document.write('<a style="color:white" href="'+'mailto:'+'cg9com'+'@'+'juno.com'+'">'+'cg9com'+'@'+'juno.com'+'</a>'); 
    
    // ]]></script>
    Text within a CDATA section will be ignored by the XML parser.

    Also, if you use document.write() to generate HTML dynamically, you need to be sure that HTML is valid.

  4. #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's interesting; presumably you could also use entities to make it valid, like with XPath?

  5. #5
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks alot


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •