Screen property of re-sized window

D

DL

Hi,

I know that window.screen defines the monitor/display's width and
height. However, when a new window is re-sized by a user how do we
know its the new window's width and height? Maybe silly question...
thanks.
 
V

VK

Hi,

I know that window.screen defines the monitor/display's width and
height.  However, when a new window is re-sized by a user how do we
know its the new window's width and height?  Maybe silly question...
thanks.

Well, window always know its actual size, just read it. You must be
wanted to ask "How to know if window was resized so to get hew width
and height?"

window host object has onresize event handler, so use it:

window.onresize = function() {
/* update values */
}

Note: there is a lost lasting peculiarity in NN and still in IE with
resize event being called twice each time: first time on resize end,
second time (optional) on window scrollbars display/removal if the new
area gets too small or too big. Doesn't happen if scrollbars are not
auto.
 
D

DL

Well, window always know its actual size, just read it. You must be
wanted to ask "How to know if window was resized so to get hew width
and height?"

window host object has onresize event handler, so use it:

window.onresize = function() {
 /* update values */

}

Note: there is a lost lasting peculiarity in NN and still in IE with
resize event being called twice each time: first time on resize end,
second time (optional) on window scrollbars display/removal if the new
area gets too small or too big. Doesn't happen if scrollbars are not
auto.

Sorry, I think my question statement was unclear.
Here's another attempt.

General Info:
I have a user interface page/form that has an iframe with id and name
of "datafrm" within it.

Current State:
using js to preset the iframe's width and height using style like
document.getElementById('datafrm').style.width = screen.width;
....

Goal:
Make the width and height of the iframe dynamic, that is about 90% of
the current browser's window height and width respectively.
This current window may be re-sized by a user any time. And when that
happens I'd like the the height and width of the iframe to reflect
that.

Browsers to be supported:
IE 7/8 and Firefox 3.5.x for now.

Thanks, VK.
 
N

nick

General Info:
I have a user interface page/form that has an iframe with id and name
of "datafrm" within it.
Okay.

Current State:
using js to preset the iframe's width and height using style like
document.getElementById('datafrm').style.width = screen.width;

Why not use CSS?

Goal:
Make the width and height of the iframe dynamic, that is about 90% of
the current browser's window height and width respectively.

Okay, so:

This current window may be re-sized by a user any time. And when that
happens I'd like the the height and width of the iframe to reflect
that.

....CSS?
 
D

DL

Why not use CSS?



Okay, so:



...CSS?

Have you tried it? It simply does not work with IE7 nor Firefox
3.5.x. By that, I mean, the iframe now defaults to a tiny one...
instead of 90% of the current window... test box OS = XP
 
N

nick

Have you tried it?  It simply does not work with IE7 nor Firefox
3.5.x. By that, I mean, the iframe now defaults to a tiny one...
instead of 90% of the current window... test box OS = XP

Many times... this is the normal way of doing this, trust me. The
percentage is relative to the width of the element containing the
iframe, not necessarily the window.

Here's a test case: http://jsbin.com/ahozi3/edit

Height is a little different. In quirks mode, percentage heights will
work the way you'd probably expect them to. In standards mode they're
a little different; you'll have to add a rule similar to this to get
percentage heights to work like they do in quirks mode:

html, body { height:100% }
 

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

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,205
Latest member
ElwoodDurh

Latest Threads

Top