browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12
AM):
[...]I want to maximize the browser window when I open a new window.[...]
function expand() {
window.moveTo(0,0);
window.resizeTo(screen.availWidth, screen.availHeight);
}
I like availWidth and availHeight, but I'd much rather work with
window.availWidth and window.availHeight. Unfortunately, they just aren't
universally available. When I ran a function to see which ones were
available, most weren't. I tried:
alert("window.width: " + window.width + "\n" +
"window.availWidth: " + window.availWidth + "\n" +
"screen.width: " + screen.width + "\n" +
"screen.AvailWidth: " + screen.AvailWidth + "\n" +
"window.innerWidth: " + window.innerWidth + "\n" +
"screen.innerWidth: " + screen.innerWidth + "\n");
What I got was:
window.width: undefined
window.availWidth: undefined
screen.width: 800
screen.availWidth: 800
window.innerWidth: undefined
screen.innerWidth: undefined
If one could place images, columns, etc., on the basis of the browser's
current WINDOW.width rather than screen.availWidth, everyone could be happy.
Yet, having as I do Internet Explorer 5.5 (and Netscape 4.6) (this isn't an
exhaustive list: this is what I use for most tests), running on Windows ME,
I can say that whatever problems I brought on myself by not having the most
up-to-date versions, I'm at least replicating the conditions of a multitude
of potential visitors, so many of whom haven't upgraded in recent years
either.
Grant Wagner <gw*****@agricoreunited.com> responded (Thursday, January 06,
2005 1:53 PM): [after quoting above code:]
- Does not do anything in Gecko-based browsers appropriately configured
- Results in an MDI window that is both too tall and too wide in Opera
7.54u1
- Results in a window that is actually wider and taller than
screen.availWidth/Height in Netscape 4 (because resizeTo() resizes the
window's viewport, not it's outter dimensions)
- Annoys the user when it does work, since they probably had their
browser the size they wanted it
Noozer" concurred (Saturday, January 01, 2005 12:59 AM): 1) Don't touch my browser size. I'm quite capable of resizing the window if I need to.
2) Don't open a new window. Your site has a browser window, ONE is all you
get. Make good use of it.
So did Sid Ismail (Saturday, January 01, 2005 7:53 AM): Don't open a new window. Don't maximise. Do not pass Go.
It's _my_ browser.
There are valid concerns here, but they can be overcome. One window is not
the ideal for some material when the user knows that the content of the new
window is just a side point and that he likely will return to the first
page. Think of the sites where you are invited to read a disclaimer, an
explanation, a definition or a chart (perhaps shipping charges). Do you
really want the new page to stay within the same window, with it coming with
the worry that the form you may have filled out (radio buttons for a survey,
street address for mail delivery of documentation, etc.) may be blank when
you return to this page? Pop-ups eliminate this worry, because the content
of the first window stays as it is until one returns and deliberately
effects a change.
(There's a lot to be said here for putting a note next to the link on the
first page: "will appear in a new window.")
I take it to be a responsibility that I not abuse screen.availWidth,
..availHeight. What I do in my window.open comment is not specify
"width=800,height=600" but use variables for the width and height of the new
window. And these variables are filled not by merely the results of getting
screen.availWidth, .availHeight, but of subtracting sufficient pixels. If
my variable is filled by "screen.availWidth - 90," I know that I am leaving
sufficient space at the bottom of the screen for the user to see his
taskbar. (I take it for granted that I also use "window.moveTo(0,0)" so
that buffer space at the top and left of the new browser window doesn't
crowd the bottom and right sides off the screen.)
Fred Oz <oz****@iinet.net.auau> brought up another point (Saturday, January
01, 2005 5:43 AM) [...] users were so pissed
off with windows opening full screen that browser makers removed the
ability for programmers to do it. Many browsers also allow the user to
stop JavaScript from resizing or moving windows.
New windows, by default in most browsers, open to the same size as the
current window. So users with full-screen windows will not notice you
setting your new window to full screen, whereas those with their
browsers set smaller will. Consider someone with a large monitor of
say 2560x1600. Or maybe with one desktop spread over two monitors. Do
you really think they want your window over their entire desktop?
Here, too, a responsible programmer doesn't let "screen.availWidth - 90"
(and its availHeight counterpart) end his settings. By setting a maximum
for the variable (if screenHght > 1200 {screenHght == 1200}), one doesn't
force these problems on the user. Quite apart from the problem of a desktop
spread over two monitors, it's just common sense that text becomes difficult
to read when the lines are too wide. Never mind that the user doesn't have
to scroll left and right -- if the line is so wide on a two-foot-wide screen
that the reader needs a straight edge sheet of paper to help him keep his
place, then the programmer has done a disservice.
Grant Wagner knew of that from his own experience when he wrote (Tuesday,
September 21, 2004 1:32 PM)(in "Re: resize browser window on load"): [...] I was recently forced to work on a laptop with a 640 x 480 display. I can not tell you how hostile most sites I visited were to that particular
resolution, let alone something smaller that you might find on a portable
device.
I know too from my own business travels what it was like to regularly work
(and have after-hours leisure) with a laptop with a 640 x 480 screen. One
has to wonder who the programmers thought they were pleasing with attractive
designs that were disfunctional. Sometimes if it wasn't just for a header
..GIF that spread past the edge of the screen (when the scroller wasn't set
for the right side), the ASCII text wouldn't have been an obstacle course of
constantly scrolling left and right.
W.H. Olives offered a solution to the problem of placement in "Re: resize
browser window on load" (Tuesday, September 21, 2004 12:50 PM): I always start a new page and insert a 75% width table, aligned to center.
I then insert a 100% table with 2 columns (right margin) and a few rows,
into that one.
This is exactly how YAHOO and GOOGLE's pages Load, like they'll fit anything they encounter. I will never go back to all of that "detect browser/detect resolution crap. Thank God for % width tables.
I agree. I have achieved what I wanted in screen placement through a
judicious use of a mix of tables, including embedded tables.
arkascha wrote in "window resize to required size" (Wednesday, October 20,
2004 9:24 AM) [...] When choosing a fixed window size things look
silly most of the time. Either you have a nearly
empty window or you have to scroll all the time...
So I want to resize the window. Resize it to what size? The size that is
required by the pages content when redered in the browser. That's all :-)
-- hmmm -- I tried around quite a lot with scrollHeigths, offsetWidth and so on, but there does not seem to be any more or less reliable solution.,
Especially not when trying to make stuff usable for different browsers.
Does anyone have a hint what else I can try, where I could look?
As long as it will be the case that programmers are presenting images --
which are almost by definition of fixed size (let's not think of how
gruesome they look when they're blown up to fit an arbitrary amount of
space) -- there is going to be the problem of blank space beyond which the
designer chose not to place additional photographs lest the page become a
scrolling nightmare on a 640-width monitor. (I use pop-ups for picture-rich
pages for this reason, but set the width at no more than about 550, but
often at less than that.)
Summary statement: can JavaScript programmers accept judicious and
responsible use of launching new windows and setting browser width?
--
David Hayes
(remove the name of the programming language from email address to make it
usable)