Jump to content

Script not working in FireFox and Safari


websiteguy

Recommended Posts

I am using a script I found for loading larger images into a div when clicking on a thumbnail link. This works fine in IE7, but does not allow the image to appear in the div on FireFox and Safari.

 

I have tried several variations after doing some research on the W3C standards. It originally used document.all, but I removed that.

 

The code:

<script language="JavaScript">
// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
function LoadGallery(pictureName,imageFile)
{
  document.getElementById(pictureName).src = imageFile;
}
</script>


</head>

 

The html:

<div id="slideshow">
  <div id="scroll"><a href="#_self" onclick="LoadGallery('holder', 'images/house-back1-lg.jpg')"><img src="images/house-back1-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/house-back3-lg.jpg')"><img src="images/house-back3-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/Beach-lg.jpg')"><img src="images/Beach-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/beach-cple-lg.jpg')"><img src="images/beach-cple-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/LapPool-lg.jpg')"><img src="images/LapPool-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/Sunset-lg.jpg')"><img src="images/Sunset-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/house-front-lg.jpg')"><img src="images/house-front-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/beachpath-lg.jpg')"><img src="images/beachpath-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/sunrise-lg.jpg')"><img src="images/sunrise-th.jpg" /></a></div>
  <div id="bigimage"><img name="holder" src="images/house-back1-lg.jpg" width="452" height="289" alt="Picture of Villa La Fiaca" /></div>
</div>

 

Sorry for all the images to filter through in the div, but I wanted to give you the whole picture.

 

I would appreciate any help on how to make this work in all browsers.

 

Link to comment
Share on other sites

it's because you did not give your image the id of "holder"; instead you gave it a name of "holder".

 

try this:

 

<script language="JavaScript">
// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
function LoadGallery(pictureName,imageFile)
{
  document.getElementById(pictureName).src = imageFile;
}
</script>



<div id="slideshow">
<div id="scroll"><a href="#_self" onclick="LoadGallery('holder', 'images/house-back1-lg.jpg')"><img src="images/house-back1-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/house-back3-lg.jpg')"><img src="images/house-back3-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/Beach-lg.jpg')"><img src="images/Beach-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/beach-cple-lg.jpg')"><img src="images/beach-cple-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/LapPool-lg.jpg')"><img src="images/LapPool-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/Sunset-lg.jpg')"><img src="images/Sunset-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/house-front-lg.jpg')"><img src="images/house-front-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/beachpath-lg.jpg')"><img src="images/beachpath-th.jpg" /></a><a href="#_self" onclick="LoadGallery('holder', 'images/sunrise-lg.jpg')"><img src="images/sunrise-th.jpg" /></a></div>
<div id="bigimage"><img id="holder" src="images/house-back1-lg.jpg" width="452" height="289" alt="Picture of Villa La Fiaca" /></div>
</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.