Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

javascrip resize window?

6:22 pm on Apr 25, 2003 (gmt 0)

10+ Year Member

I'm looking for code that would resize a window on load based on my image size.. but take into account the tool bars. aka resize the browser so that my entire image is displaied. I hear netscape resizes based on the inside window and ie the window as a whole.. i need the inside for ie.. any comments? I was think about a no tool bar popup but i realy didnt liek the idea of not giving people a tool bar unless i just ass all the controlls to a "custom" tool bar built into the page... mainly back and forth and a close button.

and now the reason for this
I'm creating a web site that is for a friend to display his art.. we have a welcome image that wont look right unless the screen fits it. If i just have the page close and open a new one without a tool bar like a pop up im afraid some peoples popup software would not let the page be veiwable. but anyway else it will take aray from the look of the site.

10:38 am on Apr 28, 2003 (gmt 0)

10+ Year Member

Hopefully this is the soloution. But if you wanted it to determine the size of the image and rezise accordingly automatically, then i dont know how to help. Hefty script i should imagine.

But otherwise just change the values to the dimensions of the image. :)

<body onload="window.resizeTo(400,500);">

It works in NN7 and IE6 dont know about others.


12:59 pm on Apr 28, 2003 (gmt 0)

10+ Year Member

that does resize but in IE it resizes the window and the tool bar take up some of the space there for the image isn't fully displayed. I think i found how to determin a window size but i'm still working on the code.. I'll post it if it works so others can use
1:20 pm on Apr 28, 2003 (gmt 0)

10+ Year Member

Please do, i would be interested to see how you do it. What if someone has addtional toolbars?

Best of luck :)

2:32 pm on Apr 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I've used this code to find the visible area in a browser window:

function getTZWindowWidth() {
var myWidth = 640;
if (document.documentElement && (document.documentElement.clientWidth document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
} else {
if (document.body && (document.body.clientWidth document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
if (document.layers) { myWidth = window.innerWidth; } // ns4 only
return myWidth;
} // end getTZWindowWidth

function getTZWindowHeight() {
var myHeight = 480;
if (document.documentElement && (document.documentElement.clientWidth document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myHeight = document.documentElement.clientHeight;
} else {
if (document.body && ( document.body.clientWidth document.body.clientHeight)) {
//IE 4 compatible
myHeight = document.body.clientHeight;
if (document.layers) { myHeight = window.innerHeight; } // ns4 only
return myHeight;
} // end getTZWindowHeight

I have to admit that its been so long since I looked into this, that I don't remember the issue involved in what looks like special-casing IE6 in standards-compliant mode. I would expect you could search Google for the term "document.documentElement.clientWidth" and come up with some helpful references. Good luck!
6:23 pm on Apr 28, 2003 (gmt 0)

10+ Year Member

So is there a solution to dynamically finding the dimensions of a gif/jpeg by using a client/server side script?

Featured Threads

Hot Threads This Week

Hot Threads This Month