You are here: irt.org | About | Feedback | 3645 [ previous next ]
Feedback on:
irt.org FAQ Knowledge Base Q877
Sent by
Daniel Teunkens on March 01, 2002 at 06:55:02:
Comments:
Goodafternoon,
It IS possible to resize the window to fit all text and images contained in it. I had this annoying customer who REALLY wanted this, so I went out and found the answer.
There is a difference between IE and Netscape (what a surprise)...
For IE, use this:
//First adjust page as much as possible to the width of any items on the page that have a fixed width (td nowrap, img, ...)
//Scroll as much to the right as possible
self.scrollBy(self.screen.availWidth, 0);
//Now we can find the amount of pixels the page is scrolled to the right, but beware that you don't stretch the window beyond the right edge of the screen (use Math.min). Do -24 because IE only gives the inner width of the window, and doesn't take into account the scrollbars
self.resizeBy(Math.min(document.body.scrollLeft, self.screen.availWidth - document.body.clientWidth - self.screenLeft - 24), 0)
//Now scroll down as much as possible
self.scrollBy(0, self.screen.availHeight);
//Do the same thing as with the width, again make sure that you don't stretch the window beyond the bottom of your sceen
self.resizeBy(0, Math.min(document.body.scrollTop, self.screen.availHeight - document.body.clientHeight - self.screenTop - 24))
//Finish off by scrolling back to the top left of the window
self.scrollTo(0,0);
For Netscape (4.8 and 6.1), use the following:
self.scrollBy(self.screen.availWidth, 0);
//Netscape uses different variables..., no need for -24, because self.outerWidth takes into account the complete width of the window
self.resizeBy(Math.min(self.pageXOffset, self.screen.availWidth - self.outerWidth - self.screenX), 0)
self.scrollBy(0, self.screen.availHeight);
//Again different variables...
self.resizeBy(0, Math.min(self.pageYOffset, self.screen.availHeight - self.outerHeight - self.screenY))
self.scrollTo(0,0);
I also tried it on Opera 6.0, but the two ways described above didn't work
Daniel Teunkens