43.
Die IE-Eigenschaft object.style.cssText (19.12.2000)
Bekanntlich lassen sich CSS-Definitionen auch als Inline-Styles, d. h. mittels STYLE-Attribut festlegen. Im IE existiert die Eigenschaft object.style.cssText, die per Scripting verändert werden kann.
Man übergibt die CSS-Definitionen analog zur Inline-Style-Notation. Im Beispiel 43 wird ein Absatz mit unterschiedlichen Formatierungen versehen, wobei das folgende Script zum Einsatz kommt.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function newStyle(Nr)
{
if (document.all)
{
var obj=document.all["absatz"];
}
if (Nr==1 && obj)
{
obj.style.cssText="Color: #FFFFFF; Background-Color: #FF0000; Font-Size: 120%";
}
if (Nr==2 && obj)
{
obj.style.cssText="Color: #0000FF; Background-Color: #FFFF00; Font-Size: 140%";
}
if (Nr==3 && obj)
{
obj.style.cssText="Color: #FF0000; Background-Color: #ABCDEF; Font-Size: 160%";
}
if (Nr==4 && obj)
{
obj.style.cssText="Color: #FFFFFF; Background-Color: #000000; Font-Size: 180%";
}
if (Nr==5 && obj)
{
obj.style.cssText="Color: #0000FF; Background-Color: #FEDCBA; Font-Size: 200%";
}
}
//-->
</SCRIPT>
|