CDATA at begining of javascript

Discussion in 'JavaScript' started by rederick, Sep 14, 2005.

  1. #1
    <script type="text/javascript"><!--//--><![CDATA[//><!--;

    function matchwo(a,b)
    {
    if (a < b && a < 0)
    document.getElementById('someid')
    // Javascript code cut for post..
    }

    //--><!]]></script>


    Does anyone know the purpose CDATA stuff at the begining? I have some code that I was given to me and it contains this. It might have something to do with the xml parser not parsing it?, but I am not sure exactlywhat this means As far as the search engines are concerned...

    Thanks
    Red.
     
    rederick, Sep 14, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need CDATA only for XHTML documents and in a much simpler form. Here's an example of what it should be:

    http://www.w3.org/TR/xhtml1/#h-4.8

    If you use HTML, you can remove CDATA alltogether.

    J.D.
     
    J.D., Sep 14, 2005 IP