R
Robi
I have the following code:
##############
var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head;
var nStyle=document.createElement("style");
// nStyle.type="text/css";
nStyle.setAttribute("type","text/css");
nHead.appendChild(nStyle);
var cssText=document.createTextNode(
'\r\t.class1 { font-family: Verdana, sans-serif; font-size:1; color:#ffff00; font-weight: bold;} '+
'\r\t.class2 { font-family: Verdana, sans-serif; font-size:1; color:#00ffff; font-weight: bold;} '+
'\r\t.class3 { font-family:Arial,sans-serif;font-size:3;color:#00ff00;font-weight: bold;} '+
'\r\t.class4 { font-family:Arial,sans-serif;font-size:3;color:#0000ff;font-weight: bold;} '+
'\r\t.class5 { font-family:Arial,sans-serif;font-size:3;color:#ff0000;font-weight: bold;} \r'
);
nStyle.appendChild(cssText);
##############
this last nStyle.appendChild(cssText); returns the following error in IE6:
Error: Unexpected call to method or property access.
Code: 0
in FF this seems to work
Can anybody point out the problem?
##############
var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head;
var nStyle=document.createElement("style");
// nStyle.type="text/css";
nStyle.setAttribute("type","text/css");
nHead.appendChild(nStyle);
var cssText=document.createTextNode(
'\r\t.class1 { font-family: Verdana, sans-serif; font-size:1; color:#ffff00; font-weight: bold;} '+
'\r\t.class2 { font-family: Verdana, sans-serif; font-size:1; color:#00ffff; font-weight: bold;} '+
'\r\t.class3 { font-family:Arial,sans-serif;font-size:3;color:#00ff00;font-weight: bold;} '+
'\r\t.class4 { font-family:Arial,sans-serif;font-size:3;color:#0000ff;font-weight: bold;} '+
'\r\t.class5 { font-family:Arial,sans-serif;font-size:3;color:#ff0000;font-weight: bold;} \r'
);
nStyle.appendChild(cssText);
##############
this last nStyle.appendChild(cssText); returns the following error in IE6:
Error: Unexpected call to method or property access.
Code: 0
in FF this seems to work
Can anybody point out the problem?