PDA

View Full Version : Need help with javascript



sumacbob
17 Sep 2006, 01:13 AM
Hi all,

I`m using the following piece of javascript which I`m using as an image viewer. It works for what I need, however the images I need to use are a little wider than my fixed width design. Using the resize in the img tags obviously works but then the image gets distorted.

I was wondering if or how I could encorporate an iframe into the script? This way I can keep the images at full size without worrying about distortion. failing that, any other suggestions? Many Thanks.



<script>
function changeImage(filename)
{
document.mainimage.src = filename;
}
</script>




A href="javascript:changeImage('http://apollo.lsc.vsc.edu/data/web/models/ecmwf/slpprecip/24.gif')">24</A>
A href="javascript:changeImage('http://apollo.lsc.vsc.edu/data/web/models/ecmwf/slpprecip/48.gif')">48</A>
<A href="javascript:changeImage('http://apollo.lsc.vsc.edu/data/web/models/ecmwf/slpprecip/72.gif')">72</A>




<img name="mainimage" src="http://apollo.lsc.vsc.edu/data/web/models/ecmwf/slpprecip/24.gif" style="border:1px solid
#e2e2e2" width="780" height="580">

Rambo Tribble
17 Sep 2006, 09:57 AM
I'm not sure I understand, but if you are trying to constrain the display to a certain size while avoiding distortion, why not place the image in a div of the desired size with overflow:hidden (or overflow:auto if you want scroll bars to appear with oversize content)?