Você está na página 1de 3

Javascript - resize table width when window gets resized

Smart questions Smart answers Smart people

Go

Find A Forum

Go

Join Directory Search Tell A Friend Whitepapers Jobs

Home > Forums > Programmers > Web Development > Javascript Forum thread216-850914

resize table width when window gets resized


Eclipse J2EE IDE
Comprehensive Solution & Support Only $29.95 - Download Free Trial

Create Ecommerce Website


Complete, easy-to-use web store. Start selling to the world.

alfalf (Programmer)

29 May 04 18:39

Hello all. I have small problem. I have determined table width, table is centered on screen, for different screen resolutions, for example: less & 800600 -> table width 100%, 1024768 -> table width 90%, 12801024 & more -> table width 80%. So, respectively, when SCREEN resolution is set to 1024768 at client side, client have 10% of free space (5% from each side), and 20% (10% from each side) if resolution is 12801024 and above. This story is OK when client have his browser maximized on screen. But, my Q. and problem is this awfull (10%-20%) waste of space if browser window is resized, and I asume that most people (like myself) rarely keeps their browser maximized (more like it's few of them opened, each already resized). I know that there's fine line of js code that easily reloads page if window is resized (onResize="window.location.href = window.location.href;" - between <body> tags), but I don't want my page to be reloaded every time window is resized (concerning more delicate web content I have here). QUESTION: Is there an "easy" way to narrow wasted side space if browser window is significantly resized from it's 'maximized' state, regardless on screen.width without window reload? Or in other words, how to widen table width to more than 80% without having page to be reloaded? Any hint is appreciated.

http://www.tek-tips.com/viewthread.cfm?qid=850914

28/02/2011

Javascript - resize table width when window gets resized

Thanx

vbkris (Programmer)

30 May 04 7:18

try this:
CODE

<table border="1" id="Tbl" width='100'> <tr><td> <input type="button" value="Increase Width" onclick="document.getElementById ('Tbl').width='300'"> </td></tr> </table>

note this will work(if it does) only in IE and NS6.x and above... Known is handfull, Unknown is worldfull

DreXor (Programmer)

31 May 04 2:38

function formattable() { document.getElementById('myTable').width = document.body.clientWidth-25; document.getElementById('myTable').height = document.body.clientHeight-50; // The -50 and -25 are just gutter dimentions, remove them to force it 100% ... PS 100% will exceed the page size and force scrollbars, perhaps -2 on both dimentions }

DreXor (Programmer)

31 May 04 2:39

forgot to mention... <body onresize="formattable()"> <script>

http://www.tek-tips.com/viewthread.cfm?qid=850914

28/02/2011

Javascript - resize table width when window gets resized

window.onresize=formattable; </script>

alfalf (Programmer)

1 Jun 04 2:49

Hey thanks man! thats exactly what I thought. You surely cut my time loss

Complete SNMP for Windows


SNMP development the way you like it to be www.logisoftar.com

Flowcharts with AJAX


Display and edit flowcharts and networks in your browser

Join | Jobs | Advertise | About Us | Contact Us | Site Policies


Copyright 1998-2011 Tecumseh Group, Inc. All rights reserved. Unauthorized reproduction or linking forbidden without express written permission.

http://www.tek-tips.com/viewthread.cfm?qid=850914

28/02/2011

Você também pode gostar