A common issue seems to be adding javascript to CDATA and the browser throwing a javascript error. To ensure the javascript works use the following code when adding CDATA:
<?php
function appendCdata($appendToNode, $text)
{
if (strtolower($appendToNode->nodeName) == 'script') { $cm = $appendToNode->ownerDocument->createTextNode("\n//");
$ct = $appendToNode->ownerDocument->createCDATASection("\n" . $text . "\n//");
$appendToNode->appendChild($cm);
$appendToNode->appendChild($ct);
} else { $ct = $appendToNode->ownerDocument->createCDATASection($text);
$appendToNode->appendChild($ct);
}
}
?>
The result should be:
<script type="text/javascript">
//<![CDATA[
function someJsText() {
document.write('Some js with <a href="#">HTML</a> content');
}
//]]></script>