[thelist] Sizing pop-up windows

Jeff jeff at c4webdesign.com
Wed Aug 23 23:11:37 CDT 2000


colleen,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Colleen McGunnigle <info at nouveauxvisages.com>
:

: Is there a way to set a pop-up window to be a specific
: width horizontally but take up the entire available screen
: area vertically? (Like the concept of setting a fixed width
: with a 100% height setting)
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the short answer is yes, but.

lemme explain why . . .

you can get the user's full screen size, both height and width, but that
doesn't take into account some of the things on the screen like toolbars,
startmenu, etc.  even then, the screen size is only available to v4+
browsers.  using screen.availHeight and screen.availWidth you can get more
accurate numbers as to the dimensions of the available screen.  however, as
you'll find out by reading the rest of this, this isn't a stellar solution.
assuming that there aren't any toolbars, startmenu, etc visible on the
screen, just replace the pixel perfect height setting with the reference to
the screen dimensions.  kinda like this:

        wURL = 'http://www.evolt.org/';
        wName = 'newWin';
        winWidth = 100;
        winHeight = screen.availHeight;
        wFeatures = 'width=' + winWidth + ',height=' + winHeight +
',top=0,left=0';
        myWin = window.open(wURL,wName,wFeatures)

(all of the below is from testing with ie5/win98 except where i mention
actually using nn4.08)

the trouble with this, that i've found, is that the available height isn't
always reported correctly.  for example, i run a resolution of 1280x1024
with all toolbars, startmenu, etc. set to auto-hide.  theoretically, i
should have just about every one of those pixels available to use.  the
weird thing is that when the window opens and i get it's size, it reports
itself as being 1053 pixels tall - not exactly what i had in mind.  (since
setting the quicklaunch bar and startmenu back to auto-hide, ie5 now reports
the available height and window height correctly as 1024.  no clue why it
wasn't doing that before.  i gave it a couple of tries with the quicklaunch
bar set to auto-hide and my startmenu 2 rows tall and it wasn't accurately
reporting the available height resulting in a window that was either the
correct size or too tall.)

now, when i try it with my startmenu set to not auto-hide, it correctly
sizes itself to take up every last pixel of the screen from top to bottom
and accurately reports it's height as 996 pixels.

i also happen to run a number of quicklaunch bars set to auto-hide at the
top of my screen.  setting that to not auto-hide and it again performs
correctly, setting itself to occupy the only the available height, in this
case 966 pixels.

however, we've run into a problem.  since it makes sense that a screen
height window should be positioned in such a way as to make it completely
viewable, it stands to reason that we'd wanna move it to top 0 and left 0.
however, with my non-auto-hidden quicklaunch bars at the top, the title bar
of the window is now completely hidden (making it almost impossible to
close) by the quicklaunch bar (which is set to always on top, btw) and there
is a gap the height of the quicklaunch bar between the bottom of my window
and the top of the startmenu.  "so just grab the full height, subtract the
available height from that and divide by two to find out how tall each bar
is.  then, instead of setting top to 0, just set it to the height of the
bar", you say confidently.  the problem is that we can't safely assume (nor
can we determine with any certainty) where those menus are placed on the
screen.  maybe i don't have any quicklaunch bars on my screen.  maybe
instead i have resized my startmenu to be 2 rows tall.  now, setting top to
0 would work just fine (again, assuming the startmenu is at the bottom).
what happens if i'm one of those users that prefers to have my startmenu at
the top, or one side or the other?  there's just no way of telling what the
user's setup is beyond just the basic dimensions.

just for kicks, i decided to fire up the cranky old bitch, netscape 4.08, to
see what happens in this browser.  my startmenu and quicklaunch bars are
still set to non-auto-hidden.  the window opens, i can't see the top or the
bottom of the window cause it's not getting accurate dimensions and opening
the window much to tall.  this is due to a quirk in nn4 that causes it to
open the window so that the inner dimensions match the height and width you
specify, instead of the outside of the window like ie4+.  however, with some
creative browser sniffing and calculations you could get around this.

i guess what i'm trying to say is that yes, you can do what you want to do,
but considering all the possibilities like startmenu
height/visibility/location, quicklaunch height/visibility/location,
pay-to-surf program banner height/visibility/location, etc. there's no
guarantee that what you're trying to do will work the way you intended.

personally, i would recommend rethinking your goals and finding another
approach.  the one you're considering is too unreliable.

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org







More information about the thelist mailing list