How to Get / Set Div and Table Width / Height

admin

Administrator
Staff member
I have a Table (or a region) and want to set it's Width and Height value to another Div (or region).

The second one is actually a Ajax Indicator modal which display a loading text when the page is asynchronously post back. here is the example

Code:
<table id="MainTable">
    <tr>
        <td>
             Content ....
        </td>
    </tr>
</table>

<div id="Progress">
     Ajax Indocator
</div>

the following javascript didn't work

Code:
document.getElementById("Progress").style.width = document.getElementById("MainTable").style.width;
document.getElementById("Progress").style.height = document.getElementById("MainTable").style.height;

It should work both on IE and FireFox. how to correct it.

I checked some other solution in StackOverFlow but I couldn't fix it.

I'm waiting to hear from you.

<hr>

Update : I use this

Code:
&lt;script&gt;
function SetSize(regionToChange, mainRegion) {
    $(document).ready(function() {
        $('#regionToChange)
 .width($('#mainRegion).outerWidth())
 .height($('#mainRegion).outerHeight());
    }); 
}
&lt;/script&gt;

and I call it like

Code:
&lt;asp:Button ID="btnReset" runat="server" SkinID="Button" Text="Reset" OnClick="btnReset_OnClick" OnClientClick="SetSize('Progress', 'MainTable');" /&gt;

But it shows me an error which can not find the object

<hr>

<strong>Update 2</strong> I see this error

<img src="https://hajloo.files.wordpress.com/2010/06/objectexpected.jpg?w=432" alt="alt text">

and in debugger I face with this

<img src="https://hajloo.files.wordpress.com/2010/06/objectexpected_developertools.jpg?w=890" alt="alt text">