473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Javascript slideshow problem in IE only

Hi all,

I've written a small piece of code to scroll through images in an array and fade in and out of each image (a slideshow).

I have a div, with an image inside which is the same size. By changing the image.src and div.backgroundImage and then adjusting the opacity I can transition the images.

It works fine in firefox and safari but special-needs IE won't update the images on this line (line 15) of code;-

Expand|Select|Wrap|Line Numbers
  1. div.style.backgroundImage="url('" + pictures[next] + "')";
  2.  
The whole code is below where slideshow is the ID of the div and image is the ID of the image object.

Expand|Select|Wrap|Line Numbers
  1. <!--
  2. var pictures=["http://bytes.com/images/1.jpg","http://bytes.com/images/2.jpg","http://bytes.com/images/3.jpg","http://bytes.com/images/4.jpg","http://bytes.com/images/5.jpg","http://bytes.com/images/6.jpg","http://bytes.com/images/7.jpg","http://bytes.com/images/8.jpg","http://bytes.com/images/9.jpg"];
  3.  
  4. var opacity = 100;
  5. var fadetime = 50;   //  milliseconds between each of the fade states
  6. var fadestep = 5;     // reduction in opacity (from 100) for each fade state - lower number = smoother transition
  7. var betweentime = 7000  // milliseconds between changing images
  8. var current = 0;
  9. var next = 1;
  10.  
  11. function startslideshow()
  12. {
  13.     opacity = 100;     // set opacity level back too 100%
  14.     div = document.getElementById('slideshow');   // name the div for easy reference
  15.     div.style.backgroundImage="url('" + pictures[next] + "')";  // set div background image as next image
  16.     $ = document.getElementById('image');  // image name for refernce later
  17.     $.src = pictures[current];  // Set the image source to the current image
  18.     changeopacity();   // kick off the function to change the opacity
  19. }
  20.  
  21. function changeopacity()
  22. {    
  23.     $ = document.getElementById('image');   //   Image name for reference later
  24.     opacity = opacity-fadestep;  //  set the opacity level for this stage of changing the opacity
  25.     $.style.opacity = opacity/100; // opacity for all browsers.
  26.     $.style.MozOpacity = opacity/100;
  27.     $.style.KhtmlOpacity = opacity/100;
  28.     $.style.filter = 'alpha(opacity='+ opacity + ')';
  29.         if(opacity <= 0)
  30.         {
  31.             $.src = pictures[next];
  32.             if (current == pictures.length-1) current = 0;
  33.             else current++;
  34.             if (next == pictures.length-1) next = 0;
  35.             else next++;
  36.             opacity = 100;
  37.             setTimeout("startslideshow()",betweentime);
  38.             return;
  39.         }
  40.         else setTimeout("changeopacity()",fadetime);
  41. }
  42. //-->
  43.  
Any ideas as to why this falls over in internet explorer ?? Thanks in advance, Phil

I also attached the whole site if this helps :-)
Attached Files
File Type: zip Black Horse Inn.zip (1.46 MB, 55 views)
Jan 19 '12 #1
1 1518
Maybe you don't need the single quotes in the url('url'). Just something I would try removing.

Edit: Sorry the above doesn't work. It's another hasLayout bug in IE. You will need to add to the style of the slideshow div "zoom:1;".

Edit Again: Sorry, it's some other bug... Ignore the previous edit and add "position:relative" to the style of the image div instead. Tested and seems to work.
Jan 26 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Carol Carrot | last post by:
I have this javascript slideshow that uses descriptions. Since the descriptions are within the javascript, the search engines don't pick up the descriptions. I can put the descriptions in the...
2
by: Jeannie | last post by:
I have a popup window which is a slideshow of about 7 images. When the popup window loads, the first image is present and then the viewer can select next or previous to scroll through the rest of...
4
by: CB US 77 | last post by:
I use a piece of javascript to create a photo gallery slideshow. The slideshow part works great, but I would like to add captions to each picture. If you want to see the html, send me an email to...
5
by: Norberto Rivera | last post by:
Is there another option that allows me to do what I want to do? Javascript does not allow me (as far as I could see: I don't know much) to delete, rename, or copy a file at the web hosting side....
6
by: UKAde | last post by:
Can anyone tell me how I can edit the script below (which I got off the net) so that any pictures shown are resized to 120px wide? Thank you Ade <SCRIPT LANGUAGE="JavaScript"> <!--
6
by: busterama | last post by:
It's probably something simple, but I just can't find the solution. I'm using the javascript slideshow code at http://javascript.internet.com/miscellaneous/fading-slide-show.html for a slideshow...
1
by: titch350 | last post by:
Does anyone know how to do a Javascript Slideshow with a loop i have a code but i cant get it to work: this is the code: picno = 0 function showpic(item) {...
5
by: The87Boy | last post by:
I'm trying to make an onmouseover and onmouseout with this script: http://www.dynamicdrive.com/dynamicindex14/leftrightslide2.htm When the mouse is over, it should change to a picture, and when...
2
helimeef
by: helimeef | last post by:
Hiya, I'm upgrading a this slideshow to Object Oriented code (so I can reuse it for other clients), and I'm having some problems getting the library to work. Here is what it's like so far:...
3
by: Gaby Sandoval | last post by:
I have a very simple javascript slideshow. It is extremely basic (see small sample below): <script language="JavaScript1.1"> <!-- //specify interval between slide (in mili seconds) var...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.