• Can someone please tell me why the wordpress editor adds the <![CDATA tag around my javascript call when switching from html to visual in the page editor. The call example is below with the good and switched version. Why the heck is it doing this, what a pain it is to keep deleting the extra junk. The script call works fine without the tags. Is there a way to stop this from happening?

    Before in HTML mode

    <script type=”text/javascript”>
    <!–
    // Load startup player
    createPlayer(“http://www.southlandbible.org/xml/musicMinistry.xml&#8221;);
    //–>
    </script>

    After switching to the visual mode.

    <script type=”text/javascript”>// <![CDATA[
    mep-nl–> <!–
    // Load startup player
    createPlayer(“http://www.southlandbible.org/xml/musicMinistry.xml&#8221;);
    //–><!–mep-nl
    // ]]></script>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi WildView,
    The editor is adding the CDATA tag because that is the proper way of inserting inline JS into an XHTML page.
    See this Wikipedia article for further information.

    Thread Starter wildview

    (@wildview)

    Thanks, but something is still buggy here. Even though I add the following [CDATA tag the editor still wants to add it again which breaks the call all together. Is this a bug in WordPress? How can I stop this from happening?

    From this…

    <script type=”text/javascript”>
    //<![CDATA[
    // Load startup player
    createPlayer(“http://www.southlandbible.org/xml/musicMinistry.xml&#8221;);
    //]]>
    </script>

    To this…. Why?

    <script type=”text/javascript”>// <![CDATA[
    mep-nl–>//<![CDATA[
    // Load startup player
    createPlayer(“http://www.southlandbible.org/xml/musicMinistry.xml&#8221;);
    //]]><!–mep-nl
    // ]]></script>

    That should not happen, unless the CDATA tags are being generated from somewhere else.
    Why don’t you try to insert that JS in your post (single.php) or page template instead so as to avoid going through the Editor all together?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Why is the editor adding [CDATA to java script calls?’ is closed to new replies.