JavaScript: set element width

    <script type="text/javascript">
    window.onload = resize;
    window.onresize = resize;

    function resize() {
    /* - FireFox does not support object reference, must use getElementby */
    var object_a= document.getElementById('a');
    var object_b = document.getElementById('b');

    /* - hidden the element DIV comments, otherwise the page will resize forever even the uesers would not notice */
    doc_comments.style.visibility = 'hidden';
/* - reduce the size first, otherwise the object_b would not resize correctly because they are under the same table */
    doc_comments.style.width = '0px';


    ..... other resize statements ......

    doc_comments.style.width = (object_b.offsetWidth - 10) + 'px';
    doc_comments.style.visibility = 'visible';
    }
    </script>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s