Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-27-2007, 04:48 PM   PM User | #1
mint suite
New Coder

 
Join Date: Jun 2006
Posts: 62
Thanks: 2
Thanked 0 Times in 0 Posts
mint suite is an unknown quantity at this point
javascript safari problem

I've got a gallery with a number of different size images. Thumbnails trigger the image swap. In safari the new image seems to remember the dimensions of the last image and (inconsistantly) resizes the new image to that of the last one. Obviously I don't want this.

Any ideas how to get around this? I assume some form of detections is needed.

Here's the head code:

Code:
<script language="JavaScript" type="text/javascript">
  if(document.images) {
    pics = new Array();
    pics[1] = new Image();
    pics[1].src = "img/style/420/Bookshelf-and-photo.jpg";
    pics[2] = new Image();
    pics[2].src = "img/style/420/Box-of-leather.jpg";
	pics[3] = new Image();
    pics[3].src = "img/style/420/Coconut-bowls.jpg";
	pics[4] = new Image();
    pics[4].src = "img/style/420/Dog-collars.jpg";
	pics[5] = new Image();
    pics[5].src = "img/style/420/Hibiscus-flower.jpg";
	pics[6] = new Image();
    pics[6].src = "img/style/420/Lanterns.jpg";
	pics[7] = new Image();
    pics[7].src = "img/style/420/Lemon-Tea.jpg";
	pics[8] = new Image();
    pics[8].src = "img/style/420/Ring-and-wood.jpg";
	pics[9] = new Image();
    pics[9].src = "img/style/420/Shells-in-bowl.jpg";
	pics[10] = new Image();
    pics[10].src = "img/style/420/Tea-Block.jpg";	
  }
    function changer(from,to) {
    if(document.images) {
    document.images[from].src = pics[to].src;
    }
  }
  
</script>
Here's the body:
Code:
<div id='main_img'>
			<img alt='' name='holder' src="img/style/420/Tea-Block.jpg" />
		</div>
		<div class='thumbs style'>
			<a onFocus="if(this.blur)this.blur()" href="javascript:;"  onMouseDown="changer('holder',10)"><img alt='' src='img/style/70/Tea-Block.jpg' /></a>
			<a onFocus="if(this.blur)this.blur()" href="javascript:;"  onMouseDown="changer('holder',1)"><img alt='' src='img/style/70/Bookshelf-and-photo.jpg' /></a>
			<a onFocus="if(this.blur)this.blur()" href="javascript:;"  onMouseDown="changer('holder',5)"><img alt='' src='img/style/70/Hibiscus-flower.jpg' /></a>
			<a onFocus="if(this.blur)this.blur()" href="javascript:;"  onMouseDown="changer('holder',3)"><img alt='' src='img/style/70/Coconut-bowls.jpg' /></a>

etc etc
mint suite is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:34 AM.


Advertisement
Log in to turn off these ads.