Forum Moderators: open

Message Too Old, No Replies

Javascript Window Resizing

howto automatically detect a res and resize window accordingly?

         

animgirl

7:32 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Hello guys and gals,

I don't know Javascript well at all. Thought I'd establish that first ;)

I'm working on a project where thumbnails are generated on a page, and when they're clicked on, the full version comes up in a Javascript opo-up window. This is database driven.

The pictures that come up as full size are quite large, and I'd like to keep the the original size. Problem is, at lower resolutions the pop-up window is so large that it doesn't fit on screen.

My question is this: is there a way, with php and/or Javascript to have the script detect the user's resolution and resize the pop-up accordingly, which would automatically resize the pic inside it?
Because this is database-driven I don't want to make several different-sized versions of the pic to accomodate this issue.

Any Ideas?
Thank you for your time,
-Elise

WebJoe

6:38 pm on Jan 18, 2004 (gmt 0)

10+ Year Member



Determine the screen size:
screen.width
and
screen.height

or the available size (without the toolbar)

screen.availWidth
and
screen.availHeight

resize the window:

window.resizeTo([i]width[/i],[i]height[/i])

Saintjude

7:15 pm on Jan 18, 2004 (gmt 0)



I thought availWidth,.. didn't work in IE, but you're right, Joe, it does.

I do reckon though, that rather than resizing the window, you might as well open it at the correct size to start with:

window.open("","_source_","width=nn,height=hh, etc ")

..but now I've thought about it, I see what Joe's at. Until you get the image, you don't know what size it is. Thing is, as a USER, I find pop-ups irritating enough without them rearranging themselves once they've opened.

The answer here is to store the dimensions of the images, perhaps in a JavaScript array.

Just an idea: Do you need to open a window at all?
To reduce the irritation factor, you could create a draggable DIV instead.

oh, and if you call window.resize( ) from the opening window, it'll resize that instead. (Just thought I'd mention!)