So, the following code works A-OK in Firefox: <script language="Javascript" type="text/javascript"> function zeroPad(num,count) { var numZeropad = num + ''; while(numZeropad.length < count) { numZeropad = "0" + numZeropad; } return numZeropad; } today = new Date(); var headID = document.getElementsByTagName("head")[0]; var css = document.createElement("style"); css.type = "text/css"; css.innerHTML = ".month td#d" + today.getFullYear() + zeroPad(today.getMonth()+1,2) + zeroPad(today.getDate(),2)+" { border: 2px solid red; color: red; }"; headID.appendChild(css); </script> Code (markup): It's supposed to generate a CSS tag with an ID based on today's date. Works fine! Internet Explorer, though Unknown Runtime Error at css.innerHTML = Code (markup): Any thoughts welcome! David
Solved my own problem. Thought I should post it here in case anyone else stumbles on this thread googling: http://www.phpied.com/dynamic-script-and-style-elements-in-ie/ David