C
Csaba Gabor
Given a DOM element (such as body, but it could be a table,
form, etc.) I'd like to have IE use window.resizeBy or
window.resizeTo to resize IE to the smallest possible size
that will NOT result in overflow, or the element being 'squashed'.
My current approach is to resize the browser to
a large amount by using
window.resizeBy(window.screen.availWidth,
window.screen.availHeight)
and then halve the width at each step in a loop until either
document.body.offsetWidth-document.body.scrollWidth changes
(indicating overflow) or the .offsetHeight of the element in question
changes (which would indicate squashing).
Having established the width, I'd like to find the smallest
height, but I'm not sure of the best way. The indicator
that (I think) I'd like to use is when the scrollbar goes active,
but I don't know how to test for that. Perhaps someone could
expand on this idea, or maybe there is a flat out different approach.
Note, I am using IE as a COM object (IE 6 on Win XP Pro) so
only an IE solution is needed. Typical use will be for automatically
sizing dialogs.
Also, I'm not happy with the initial resizing because if the page
is too large to start with, the resizing might not get rid of the
overflow, but then I am still stuck with the changed window size.
Is there a fixed correlation between window.resizeTo and one
of the size measurements such as
document.body.offsetWidth and Height?
Finally, here is a simple test page:
<body>
<form method=get action='' style='border:1px solid red'>
<span id=myspan style='border:1px solid blue'>
<button id=btnOK><u>O</u>K</button>
<button id=btn2><u>T</u>est me</button>
<button><u>C</u>ancel</button></span></form>
</body>
Thanks for any tips,
Csaba Gabor from Vienna
form, etc.) I'd like to have IE use window.resizeBy or
window.resizeTo to resize IE to the smallest possible size
that will NOT result in overflow, or the element being 'squashed'.
My current approach is to resize the browser to
a large amount by using
window.resizeBy(window.screen.availWidth,
window.screen.availHeight)
and then halve the width at each step in a loop until either
document.body.offsetWidth-document.body.scrollWidth changes
(indicating overflow) or the .offsetHeight of the element in question
changes (which would indicate squashing).
Having established the width, I'd like to find the smallest
height, but I'm not sure of the best way. The indicator
that (I think) I'd like to use is when the scrollbar goes active,
but I don't know how to test for that. Perhaps someone could
expand on this idea, or maybe there is a flat out different approach.
Note, I am using IE as a COM object (IE 6 on Win XP Pro) so
only an IE solution is needed. Typical use will be for automatically
sizing dialogs.
Also, I'm not happy with the initial resizing because if the page
is too large to start with, the resizing might not get rid of the
overflow, but then I am still stuck with the changed window size.
Is there a fixed correlation between window.resizeTo and one
of the size measurements such as
document.body.offsetWidth and Height?
Finally, here is a simple test page:
<body>
<form method=get action='' style='border:1px solid red'>
<span id=myspan style='border:1px solid blue'>
<button id=btnOK><u>O</u>K</button>
<button id=btn2><u>T</u>est me</button>
<button><u>C</u>ancel</button></span></form>
</body>
Thanks for any tips,
Csaba Gabor from Vienna