Clip Image inside div

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi, I have a DIV in my webpage called largeImage declared as such

 <div id="largeImage" style="width:360px; height: 238px;" />

When someone does a mouseover on a thumbnail I am showing the big
image using the following code

function showImage(imageName)
document.getElementById('largeImage').innerHTML = '<img src="./
_listingImages/' + imageName + '" style="width:360px;height:238px;" /
Quoted text here. Click to load it

My problem is that sometimes the large image can be bigger then the
original DIV so I want to cut off the excess so to speak so that the
large image is not bigger than the original div.

Any help appreciated
Thanks in advance

Re: Clip Image inside div


Quoted text here. Click to load it

I hope you have some fallback, like a link, for users who have decided (or
whose superiors have decided) to switch of JavaScript execution.

Quoted text here. Click to load it

Why invalid markup? There's never an acceptable reason to omit the alt

Why do you use innerHTML instead of simply changing the value of the
element's src attribute (and possibly the alt attribute) in the code?

Quoted text here. Click to load it

This part looks easy, though I might miss something since the answer looks
too obvious (but answers often are): add the following into your style

#largeImage { overflow: hidden; }

Jukka K. Korpela ("Yucca")

Site Timeline