By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

geting hold of image???

P: n/a
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>
--------------------------------------
thank you
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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>
--------------------------------------
thank you


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

[This could disproportionalize the pics]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
LJL
"riki" <ri******@hotmail.com> wrote in news:bv**********@ls219.htnet.hr:
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>
--------------------------------------
thank you


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:open_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
Jul 20 '05 #3

P: n/a
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...
Jul 20 '05 #4

P: n/a
> 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
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.