geting hold of image???

R

riki

hi,
i've asked this question before and didn't get an answer...maybe i didn't
explain it well so i'll try again...
--------------------------------------
main.html
i'm calling popUp like
window.open('/path/pic.jpg','popUp','toolbar=no, location=no etc.')
now...all pics don't have the same width and height so i don't wanna fix
manualy width and height for each pic...
--------------------------------------
popUp.html
instead i would like to write a function in the popUp.html that resizes the
window, but i don't know how to get hold of pic object so i could extract
width and height of individual pic...
<script lang=jscr>
picWidth=?
picHeight=?
</script>
 
E

Evertjan.

riki wrote on 06 feb 2004 in comp.lang.javascript:
hi,
i've asked this question before and didn't get an answer...maybe i
didn't explain it well so i'll try again...
--------------------------------------
main.html
i'm calling popUp like
window.open('/path/pic.jpg','popUp','toolbar=no, location=no etc.')
now...all pics don't have the same width and height so i don't wanna
fix manualy width and height for each pic...
--------------------------------------
popUp.html
instead i would like to write a function in the popUp.html that
resizes the window, but i don't know how to get hold of pic object so
i could extract width and height of individual pic...
<script lang=jscr>
picWidth=?
picHeight=?
</script>

define the container measurements
and give the pic style width and height of 100%

[This could disproportionalize the pics]
 
R

riki

i was wondering if it's possible to get hold of image object in popUp.html?

i dont know, something like this

window.document.XXX

and XXX represents image object...if it's possible than i could extract
exact width and height so pic wouldn't get disproportionalized...
 
L

LJL

riki said:
hi,
i've asked this question before and didn't get an answer...maybe i
didn't explain it well so i'll try again...
--------------------------------------
main.html
i'm calling popUp like
window.open('/path/pic.jpg','popUp','toolbar=no, location=no etc.')
now...all pics don't have the same width and height so i don't wanna
fix manualy width and height for each pic...
--------------------------------------
popUp.html
instead i would like to write a function in the popUp.html that
resizes the window, but i don't know how to get hold of pic object so
i could extract width and height of individual pic...
<script lang=jscr>
picWidth=?
picHeight=?
</script>

Have you thought of using a function call that sends the width and height
of the image? I get the idea that you want the function to figure out the
height and width automatically, but I think you need to load the image to
get that info (I may be wrong on that, but I don't know how it would be
done). You do, however, already know the image's actual size and name.

In other words, if the window.open function is called "open_new()", and you
know the size of the images you want to show, just do this:

The HTML looks like this:

<IMG SRC="thumbnail001.jpg" WIDTH="80" HEIGHT="60"
onClick="open_new(400,300,'bigimg001.jpg');">

or

<A HREF="javascript:eek:pen_new(400,300,'bigimg001.jpg');"><IMG
SRC="thumbnail001.jpg" WIDTH="80" HEIGHT="60"></A>



The JS looks like this:

function open_new(imgwid,imght,imgname) //width, height and name are sent
{
imgwid+=40; // adds 40 pixels in width - adjust as needed
imght+=60; // adds 60 pixels in height - adjust as needed
window.open(imgname,'_blank','width='+imgwid+',
height='+imght+',directories=0,menubar=0,resizable=1,scrollbars=0,status=0,
toobar=0');
}

Good luck, LJL
 
R

riki

Have you thought of using a function call that sends the width and height
of the image? I get the idea that you want the function to figure out the
height and width automatically, but I think you need to load the image to
get that info (I may be wrong on that, but I don't know how it would be
done).

i'm working with about 100 pics and i thought that i could avoid manually
fixing width and height for every pic.
but it seems that i'll have to do it harder way .
the idea was to get hold of image object in popUp window after it was
load...
popUp.html
-------------------------
<body onLoad="javascript: getImage();">

but my efforts failed :)))

anyway, thank you for your answer...i'll try to do it your way
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top