473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Window Resize

I would like to automatically resize a window to its content. I was thinking
of using an outer table to detect the size of my content, then use
window.resizeTo( ).

The problem is I'm not sure how I can determine the size of what I think is
referred to as the 'chrome' - the window borders, toolbars, etc.

Is there a way to determine the height and width of the chrome so that I can
supply the correct parameters to the resizeTo method?
Jul 23 '05 #1
2 3169
Peter wrote:
I would like to automatically resize a window to its
content. I was thinking of using an outer table to
detect the size of my content, then use window.resizeTo( ).

The problem is I'm not sure how I can determine the size
of what I think is referred to as the 'chrome' - the
window borders, toolbars, etc.

Is there a way to determine the height and width of the
chrome so that I can supply the correct parameters to the
resizeTo method?


The dimension of the top and left chrome can be determined on browsers
that expose the screen offsets of their window to scripting, given a
mouse input event. By reading the mouse's screen co-ordinates, and its
viewport co-ordinates and using the difference to give the screen
co-ordinates of the viewport. The difference between the screen
co-ordinates of the window and the screen co-ordinates of the viewport
give the dimensions of the chrome at the top of the window and the
chrome to the left.

The screen co-ordinates of the window are not universally available in
browser object models (and in framesets the values don't necessarily
have the same meaning).

The other proposed possible strategy for determining the chrome
dimensions in total is to measure the viewport dimensions, re-size the
window to the original viewport dimensions and then re-measure the
viewport dimensions. The difference being the total dimensions of the
chrome (left+right and top+bottom), assuming that the second set of
viewport dimensions didn't drop to zero, which would invalidate the
results.

Obviously re-sizing the window a couple of times is not going to look
that good to the user. And these days the ability to re-size a browser
window is subject to user veto, so it will often not work at all.

A better approach is probably to adopt a fluid HTML design that adapts
to whatever size the user's window happens to be.

Richard.
Jul 23 '05 #2
Thank you Richard for the thorough response. That helps a lot. As far as
user experience goes, I agree with your opinion, but in this case, it is for
a private web application and the need is for the browser to conform to the
size of the content. Since I have only one browser to target, this should be
doable.

Thanks again,
Peter

Richard Cornford wrote:
Peter wrote:
I would like to automatically resize a window to its
content. I was thinking of using an outer table to
detect the size of my content, then use window.resizeTo( ).

The problem is I'm not sure how I can determine the size
of what I think is referred to as the 'chrome' - the
window borders, toolbars, etc.

Is there a way to determine the height and width of the
chrome so that I can supply the correct parameters to the
resizeTo method?


The dimension of the top and left chrome can be determined on browsers
that expose the screen offsets of their window to scripting, given a
mouse input event. By reading the mouse's screen co-ordinates, and its
viewport co-ordinates and using the difference to give the screen
co-ordinates of the viewport. The difference between the screen
co-ordinates of the window and the screen co-ordinates of the viewport
give the dimensions of the chrome at the top of the window and the
chrome to the left.

The screen co-ordinates of the window are not universally available in
browser object models (and in framesets the values don't necessarily
have the same meaning).

The other proposed possible strategy for determining the chrome
dimensions in total is to measure the viewport dimensions, re-size the
window to the original viewport dimensions and then re-measure the
viewport dimensions. The difference being the total dimensions of the
chrome (left+right and top+bottom), assuming that the second set of
viewport dimensions didn't drop to zero, which would invalidate the
results.

Obviously re-sizing the window a couple of times is not going to look
that good to the user. And these days the ability to re-size a browser
window is subject to user veto, so it will often not work at all.

A better approach is probably to adopt a fluid HTML design that adapts
to whatever size the user's window happens to be.

Richard.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
2
by: Charles Packer | last post by:
From one of the online Javascript tutorials, I learned how to open a new window and set its size. I'm building a page that has several small photographs, and I want to let the viewer examine...
4
by: David Logan | last post by:
Hello, I am trying to open a window with a graphic in it and have the window be exactly the correct size of the image. Is there anyway to do this that will work on any browser on any OS???? ...
6
by: David Hayes | last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12 AM): > > >I want to maximize the browser...
1
by: jdapro | last post by:
Hi - thanks for reading this out there! I'll be quick about it: I've got this row of images (in the end there will be more rows of pics as well). When a user clicks on the image, I want a new...
3
by: johkar | last post by:
My child window has this script. "temp" is simply the value of the select list which I am passing onchange. I get a permission denied error in IE when executing selectOption. function...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
2
by: daveyand | last post by:
Hey Guys I am able to detect a window resize using the following code: window.onresize = function () { if(document.getElementById("parent_for_video").style.display != "none") {...
7
by: Dr J R Stockton | last post by:
I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in IE6, IE7, Firefox 2, and wherever else practicable, with the control labelled F.X0 fully visible at the top of the window and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.