with obj.style
 .height
 .width
 .left
 .top
end with

解决方案 »

  1.   

    在操作前,记录一下div的一些属性值就可以了.
    还原时把值再写回去.
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> test </TITLE>
    <script type="text/javascript">
    //这里我只保存了divTest的两个属性,多的你自己定义
    var objProperty_width;
    var objProperty_height;
    function tryShow()
    {
    var objshow = document.getElementById("divTest");
    objProperty_width = objshow.style.width;
    objProperty_height = objshow.style.height;
    var obj = document.getElementById("divContainer");
    var divs = obj.getElementsByTagName("DIV");
    for(var i = 0;i<divs.length;i++)
    {
    divs[i].style.display = "none";
    }
    //alert(divs.length);
    objshow.style.width = obj.style.width;
    objshow.style.height = obj.style.height;
    //objshow.style.backgroundColor = obj.style.backgroundColor
    objshow.style.display = "";
    alert(objProperty_width); } function tryReset()
    {
    var objshow = document.getElementById("divTest");
    var obj = document.getElementById("divContainer");
    var divs = obj.getElementsByTagName("DIV");
    for(var i = 0;i<divs.length;i++)
    {
    divs[i].style.display = "";
    }
    objshow.style.width = objProperty_width;
    objshow.style.height = objProperty_height;
    }
    </script>
    </HEAD><BODY>
    <div id="divContainer" style="width:300px;background-color:#FFEEDD;height:250px;">
    <div id="div1"><p>test1</p></div>
    <div id="div2"><p>test2</p></div>
    <div id="divTest" style="background-color:#DDFFEE;width:100px;height:50px;"><p>the div used for showing</p></div>
    </div>
    <div>
    <input type="button" value="try show" onclick="tryShow()"/>
    <input type="button" value="try reset" onclick="tryReset()"/>
    </div>
    </BODY>
    </HTML>