How to code your own resize events ?

J

JezB

I need to code my own resize event, and Im not sure how.

I have a DIV whose width I always want to be the browser height (the inner
pane, excluding the toolbars, status bar etc) - 200 points (say). I can't
use a height % for this, so as I understand it I need to code my own
onresize event.

Trouble is, I know almost nothing about javascript, so I dont know how to
get the browser window height or set the DIV height.
The solution should be portable if possible (ie. run on IE, Netscape,
Mozilla, etc).
 
J

JezB

I want to avoid using HTML tables - W3C does not recommend this approach for
managing page layout. I'm trying to use styles exclusively.
 
E

Eliyahu Goldin

No, you should not need any event for that. This is not the way how you
handle this sort of things. You can reach almost any resizing effect by
proper laying out your page. I recommend using html tables (<table>) for all
sorts of layout. Browsers know how to handle them well. For your particular
task place your <div> in a row with height=100%. Make another row with
height=200px on top of that and place there another <div>.

Even with a single <div> you can play with padding and margin attributes and
you might achieve your goal without any table. But still I would recommend a
table since different browser handle padding and margins differently.

Eliyahu
 
J

JezB

Well, styles can dictate positioning and size as well as colours, fonts etc.
My DIV has a style which has a width property of 100%, but its the height
property that I'm having trouble with - I cannot use a % or hardcode a
specific number of pixels - I need to calculate it in a javascript onResize
event, based on the browser height.
 
E

Eliyahu Goldin

I wish you well in trying to avoid tables. Developers use tables not because
they love them, rather for the simple reason that with a table you can in a
number of minutes achieve what you have been trying to for hours and days
without tables.

It's not clear for me how is using styles connected to event handling that
you mentioned in your original post.

Eliyahu
 
G

Guest

using divs and styles saves a LOT of time in the long run compared to tables. How often have you made a site that uses it's original interface. Typically I end up changing the interface at least once during development because it becomes apparent that a different design would work better. Design changes with divs and stylesheets can propogate across the whole site instead of having to change every table. Also, as I get better with divs, styling becomes faster than with tables. To address the original question, find a way to do this with percentages. Download mozilla and use their dom inspector it really, really helps when designing layouts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top