Closed Thread Icon

Topic awaiting preservation: Help cobbling JS for open win > image fit (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8380" title="Pages that link to Topic awaiting preservation: Help cobbling JS for open win &amp;gt; image fit (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Help cobbling JS for open win &gt; image fit <span class="small">(Page 1 of 1)</span>\

 
warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 11-05-2002 21:02

JS is definitely not my strong suit. I can cobble some simple scripts together with some trial-n-error. That's what I'm doing right now, but I would like some help to expediate matters.

I have a thumbnail. Its linked to an image. The image opens in a new window.
How do I fit the new window to the image's dimensions?

I'll be using whatever.document.write('<html>');
for the new window, but I'm having problems figuring out how to get the height/width and passing them on.

Mucho appreciated.

edit: Wrong forum. Sorry about that. Somebody capable willing to move it?


[This message has been edited by warjournal (edited 11-05-2002).]

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 11-05-2002 23:03


From the reading I've been doing, I can set the height/width, but not grab.

Veneficuz
Paranoid (IV) Inmate

From: A graveyard of dreams
Insane since: Mar 2001

posted posted 11-05-2002 23:25

I had no problem grabbing the size of an image using document.getElementById["name"].width or document.getElementById["name"].height. You just have to make sure that the images are loaded before trying to get the dimensions. Doesn't that method work for you?


[edit] I write two lines and still manage to get a couple of typos [/edit]
_________________________
Anyone who has lost track of time when using a computer knows the propensity to dream, the urge to make dreams come true and the tendency to miss lunch.
- copied from the wall of cell 408 -

[This message has been edited by Veneficuz (edited 11-05-2002).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 11-06-2002 00:14

You really need the size of the full image before it is loaded which is tricky.

2 solutions:

1. Use server-side scripting - you can then generate the thumbnails dynamically.

2. Resize the window after you have popped it up.

I'll move this to JavaScript/DHTML now.

___________________
Emps

FAQs: Emperor

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 11-06-2002 02:05

wj,

I have a popup script that's a little dated but opens a new window that resizes itself to an image's dimensions. The script allows you to hard code the dimensions in the function but that is optional since the actual image size is detected and used for the resize once the onload trigger fires.

Please take a look at this http://www.bugimus.com/gurus/image_popup/imagepopup.html

I would be happy to help modify it if it does not meet your specific needs. I hope it can help.

. . : slicePuzzle

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 11-06-2002 02:14

I was thinking about #2 that Emps mentioned and Bugs supplied the solution for. Kudos.

Questions time
How about something like:
1) onClick load image
2) grab height/width
3) write the doc to new window

I think that will work and keep JS in the new window to a minimum/null.
Feasible?



« BackwardsOnwards »

Show Forum Drop Down Menu