This raises another point. The object of reading the screen resolution is to adjust your window layout based on what the user is able to see, not what the user chooses to see. If you plan to readjust the display to fit a two-inch window, you're building a funhouse mirror, not a serious application. The user can resize the window at any time. If you want to set the display based on the current window width and then the user resizes the window (again!), you'll need to read this information every time the page is refreshed and then pass the new dimensions to the application after every refresh if that's your criterion for success. This path is neither easy nor necessary.
If the user can easily make the window large enough to see your content, allowing for your navigation bar as well as the user's toolbars, then you've succeeded. Although it's possible to read the window size, it's probably better not to bother. Reading the screen size lets you determine the dimensions readily available to the window.
So, let's plan to read the available screen dimensions at login.
<script language="javascript">
<!--
function screenDimensionsGet() {
if (self.screen.availWidth) {
document.Login.ScreenWidth.value =
self.screen.availWidth;
}
if (self.screen.availHeight) {
document.Login.ScreenHeight.value =
self.screen.availHeight;
}
}
// -->
</script>
<body onLoad="screenDimensionsGet()">
Now define a typical login form named Login. In addition to Username and Password, give it hidden fields to hold the settings to (hopefully) be provided by the javascript above. If the informatation can't be obtained - perhaps javascript is off - provide default values. Most monitors can handle at least 800 x 600. Subtracting the status bar leaves 800 x 567 when I set my resolution this low.
<form name="Login" method="post" action="gate.cfm"> Please log in <p> Username: <input type="text" name="Username" value=""><br> Password: <input type="password" name="Password" value=""><br> <input type="hidden" name="ScreenWidth" value="800"> <input type="hidden" name="ScreenHeight" value="567"><br> <input type="submit" name="Go" value="Send"> </form>
<cfparam name="form.Go" default=""> <cfif len(trim(form.Go))> <cfoutput> Username: #form.Username#<br> Password: #form.Password#<br> Available Screen Width: #form.ScreenWidth#<br> Available Screen Height: #form.ScreenHeight# </cfoutput> </cfif>