Note: Please check JavaScript Utility Functions Note.

Here is short JavaScript function which creates and returns a script node based on the string you specify as parameter:


/*Define the namespaces*/
var JavaScript = {};
JavaScript.Utils = {};
JavaScript.Utils.DOM = {};

JavaScript.Utils.DOM.CreateScriptElement = function(scriptValue) {
var node = document.createElement("script");
node.setAttribute('type', 'text/javascript');

if (node.canHaveChildren == null || node.canHaveChildren)
node.appendChild(document.createTextNode(scriptValue));
else
node.text = scriptValue;

return node;
};