Popup - detect and autosize to image

J

Jake

Hi,
I have a page with a bunch of thumbnails that when clicked, open the full
size image in a new window. They are all different sizes and its a bit
unprofessional looking. I'd like to find a component or script that will
detect the size of the linked image and create a popup correctly sized to
the image. Would have no toolbar, buttons,scrolling, etc. Just a clean,
correctly sized window.

Any way to do this?

TIA
 
M

McKirahan

Jake said:
Hi,
I have a page with a bunch of thumbnails that when clicked, open the full
size image in a new window. They are all different sizes and its a bit
unprofessional looking. I'd like to find a component or script that will
detect the size of the linked image and create a popup correctly sized to
the image. Would have no toolbar, buttons,scrolling, etc. Just a clean,
correctly sized window.

Any way to do this?

TIA


Will this help? Watch for word-wrap.

<html>
<head>
<title>enlarge.htm</title>
<script type="text/javascript">
function enlarge(image) {
var i = new Image();
i.src = image;
var x = i.width;
var y = i.height;
// window.status for degugging:
window.status = image + " = " + x + " x " + y + " pixels";
var z = "scrollbars=no,width=" + (x+20) + ",height=" + (y+20);
window.open(image,"image",z);
}
</script>
</head>
<body>
<a
href="javascript:enlarge('http://www.google.com/intl/en/images/logo.gif');"
border="1" width="143" height="59" alt="Click to enlarge"></a>
</body>
</html>
 
M

Mark Schupp

first you will need to get the actual size of the image. best time to do
this is when you upload the image (keep info in a database so that you don't
have to extract it every time a page is displayed). If you know the size at
that time use it. otherwise see http://www.aspfaq.com/show.asp?id=2170 for
info about extracting size.

Embed the size in your window.open statement (in the client-side code you
generate) for each thumbnail link.
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top