var script = document.createElement('script'); script.setAttribute('type','text/javascript'); script.innerHTML = "var theRoot = document.getElementById('"+ pageName +"');var theHandle= theRoot.childNodes[0]; Drag.init(theHandle, theRoot);" outside.appendChild(script); Code (markup): Is what I currently have - which works in anything but IE and its stupid lack of DOM methods. I have tried just adding it with innerHTML, but that stops it working in any browser - so what is the best (if any) way to do this?
var data = "var theRoot = document.getElementById('"+ pageName +"');var theHandle= theRoot.childNodes[0]; Drag.init(theHandle, theRoot);"; if (window.ActiveXObject) //ie script.text = data; else script.appendChild document.createTextNode(data)); PHP: I don't see why you are doing it like this though.