Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

<![CDATA[ problem in javascript

Options
  • 12-01-2006 7:25pm
    #1
    Registered Users Posts: 7,677 ✭✭✭


    Hi,

    I have some javascript as follows

    <script type="text/javascript">
    <![CDATA[

    //functions in here

    ]]>
    </script>

    But I am getting a syntax error in char 2 of <![CDATA[

    I can't get any of my javascript to run because of it

    Can anyone help me why please

    Thanks


Comments

  • Closed Accounts Posts: 33 sean_or99


    Not completely sure as to what you are trying to do. Firstly a CDATA section a section used in an XML doc to instruct the parser to interpret that section as character data. Are you wrapping some JavaScript in a CDATA section for transformation with an xsl???

    If you have no idea what I am writing about, just delete <![CDATA[ and ]]> and it should work.


  • Registered Users Posts: 7,677 ✭✭✭Trampas


    Sorry I am putting it into html

    I need to put it in so I can get around the W3C strict xhtml validation.


  • Closed Accounts Posts: 324 ✭✭madramor


    try
    <script type="text/javascript">
    /* <![CDATA[ */
    //functions in here 
    /* ]]> */
    </script>
    


  • Closed Accounts Posts: 33 sean_or99


    Now I understand.

    Here is a strict XHTML Page:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html 
        PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <script type="text/javascript">
                <![CDATA[
    
                 ]]>
             </script>
            <title>XHTML Example</title>
        </head>
    
    
        <body>
            <p>This is a tiny example of an <acronym title="Extensible HyperText 
            Markup Language">XHTML</acronym> document.</p>
        </body>
    </html>
    

    (most of it copied from example at wikipedia)

    Try this in your browser. If it works then recheck your code, if it fails, then its probably something to do with whatever browser you are running.


  • Registered Users Posts: 7,677 ✭✭✭Trampas


    madramor wrote:
    try
    <script type="text/javascript">
    /* <![CDATA[ */
    //functions in here 
    /* ]]> */
    </script>
    


    Cheers mate thats the one.

    Thanks sean for your help to.

    hopefully i will be some help for you in future


  • Advertisement
Advertisement