if(screen.Width==800)
 document.all.id.style.fontSize='9pt'
else
 document.all.id.style.fontSize='11pt'

解决方案 »

  1.   

    <STYLE>
    .text1 {font-color:#0000ff}
    </STYLE>
    <SCRIPT>
    function fnInit(){
       var oStyleSheet=document.styleSheets[0];
       var oRule=oStyleSheet.rules[0];
       oRule.style.backgroundColor="#0000FF";
    }
    </SCRIPT>
    <font class="text1">text</font>
    <input type="button" onclick="fnInit()">
      

  2.   

    if(screen.Width == 800)
    {
    document.write("<style>")
    ocument.write(".text1{Font-size:9pt;Text-align:center} ")
    ocument.write(".text2{Font-size:9pt;Color:#FF0000;Text-align:center}")
    ocument.write(".text3{Font-size:9pt;Color:#3F44A8;Text-align:center")")
    ocument.write("</style>")
    }
    else
    {
    document.write("<style>")
    ocument.write(".text1{Font-size:11pt;Text-align:center} ")
    ocument.write(".text2{Font-size:11pt;Color:#FF0000;Text-align:center}")
    ocument.write(".text3{Font-size:11pt;Color:#3F44A8;Text-align:center")")
    ocument.write("</style>")
    }
      

  3.   

    id 是什么啊?是不是在<div>中定义的名称?如果是的话,那不是要定义很多名称了吗?