在 IE 下 可以这样些:
document.getElementById("main").style.width = document.body.clientWidth - 194;但firefox 却不支持啊

解决方案 »

  1.   

    document.getElementById("main").Attributes.Add("width",document.body.clientWidth - 194);
      

  2.   

    忘了attributes.add是C#的 
    你用document.getElementById("main").setAttribut("width",document.body.clientWidth - 194);
      

  3.   

    补充一点 setAttribute设置style和onclick这些属性在IE中是行不通的。所以在某些属性上我们必须这么写
    document.getElementById("testbt").className = "bordercss";
    document.getElementById("testbt").style.cssText = "color: #00f;";
    document.getElementById("testbt").style.color = "#00f";
    document.getElementById("testbt").onclick= function () { alert("This is a test!"); }
      

  4.   


    document.getElementById("main").style.width = (document.body.clientWidth - 194) + "px";
      

  5.   

    测试了,都不可行 ,3楼的只是在IE中有效,不支持firefox
      

  6.   

    document.getElementById("main").style["width"]= (parseInt(document.body.clientWidth) - 194) + "px";
    不可能不行
      

  7.   

    需要给width的长度值加上一个单位, 4楼 6楼的都对。lz可以看看这个帖子:http://topic.csdn.net/u/20100714/20/759e2fc2-a619-42b8-a8e9-6fcab711f7cb.html?95241 希望对你有所帮助