Secondary window won't resize

C

Charles Packer

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
either a full size image or an image with supporting detail.
It's the same idea used on lots of Web sites that show thumbnails
where you click on one and the full-size image is displayed in a
new window. However, I have different-sized images that will appear
in the new window, and I want it to resize automatically to
accommodate each new image. I don't know how to do that. The page
in question is at

http://cpacker.org/misc/petersquare

What happens with this page is that the new window has the
dimensions of the first image first clicked on. Click on another and
the new image appears in the window, but the window retains the dimensions
of the first image.

Also, "resizable=no" didn't work for me -- I could still drag on
the lower right corner of the new window and resize it manually.
I assume that's what the option is supposed to control.

Oddly enough, when I bundled the Javascript statements in a <SCRIPT...</SCRIPT>
bracket above the </HEAD> in the manner of some Web sites, the new window
retained the height of the first image, but was always about 100 pixels wide.

I browsed this newsgroup and there are a lot of threads about this issue.
learned about window.resizeTo, but that didn't work. For example,
I tried
function A1() { window.resizeTo(865,795); window.open('stpeters.jpg'...
but still got the tall skinny window I mentioned above.
Any help would be appreciated.
 
D

DU

Charles said:
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
either a full size image or an image with supporting detail.
It's the same idea used on lots of Web sites that show thumbnails
where you click on one and the full-size image is displayed in a
new window. However, I have different-sized images that will appear
in the new window, and I want it to resize automatically to
accommodate each new image. I don't know how to do that. The page
in question is at

http://cpacker.org/misc/petersquare

What happens with this page is that the new window has the
dimensions of the first image first clicked on. Click on another and
the new image appears in the window, but the window retains the dimensions
of the first image.

So your code needs to store the url of the ith image so that if an jth
image is clicked, then the jth image dimensions will be passed as
parameters in the window.open call.
Also, "resizable=no" didn't work for me -- I could still drag on
the lower right corner of the new window and resize it manually.

Which browser does that? Anyway, for the sake of usability and
accessibility to content, windows should *always* be resizable.
I assume that's what the option is supposed to control.

Oddly enough, when I bundled the Javascript statements in a <SCRIPT...</SCRIPT>
bracket above the </HEAD> in the manner of some Web sites, the new window
retained the height of the first image, but was always about 100 pixels wide.

As soon as there is a parsing problem in the windowFeatures string,
browsers stop processing that string and renders a secondary window with
default values (or persistent data).

window.open('stpeters.jpg', ' ','width-865,height=795,resizable=no'
is in your page's code.
width-865 will cause parsing problem. Browsers will try to see if
"width-865,height" is actually a valid windowFeature.
I browsed this newsgroup and there are a lot of threads about this issue.
learned about window.resizeTo, but that didn't work. For example,
I tried
function A1() { window.resizeTo(865,795); window.open('stpeters.jpg'...
but still got the tall skinny window I mentioned above.

No. You're trying to resize the current window, not the one you want to
create (and which is not created yet). Anyway, many browsers give their
users the veto power to neutralize resizeTo() calls, so this is not
reliable nor recommendable anyway.
Any help would be appreciated.

Have a look at this page which addresses your problem:
http://www10.brinkster.com/doctorunclear/HTMLJavascriptCSS/EnlargeThumbnail.html

Also but more complex
Create a sub-window and dynamically DOM-insert an image
http://www10.brinkster.com/doctorunclear/HTMLJavascriptCSS/DynamicInsertionDOMImageInPopup.html

DU
 
C

Charles Packer

DU said:


Well, that page has a banner that says "This file still under
construction."
However, your followup, while not exactly an answer to three decimal
places, so to speak, did give me the strength to flail onward, and my
latest version of
http://cpacker.org/misc/petersquare
gets me the right-sized secondary image, but only after two clicks.
The extra click simply kills the previous secondary window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top