以下是宽度变化的示例,高度也可参考:
01 | <script type= "text/javascript" > |
02 | function initWidth() { |
03 | var bodyWidth = document.compatMode == "BackCompat" ?document.body.clientWidth:document.documentElement.clientWidth; |
04 | document.getElementById( "Content" ).style.width = bodyWidth - 180; |
05 | } |
06 | initWidth(); |
07 | if (document.attachEvent) { |
08 | window.attachEvent( 'onresize' , initWidth); |
09 | } else { |
10 | window.addEventListener( 'resize' , initWidth, false ); |
11 | } |
12 | </script> |