By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,961 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,961 IT Pros & Developers. It's quick & easy.

Undefined error for picture slideshow in Chrome & Firefox, works in IE

P: 1
I have a picture slideshow within a <td> tag and am getting an undefined error underneath the slideshow only in firefox and chrome. Works great in IE. My code is below. Guidance is very much appreciated.


Expand|Select|Wrap|Line Numbers
  1. <td width="50%" style="text-align: center; vertical-align: middle;">
  2.     <script language="JavaScript1.2">
  3.  
  4. /***********************************************
  5. * Flexi Slideshow-  Dynamic Drive (www.dynamicdrive.com)
  6. * This notice must stay intact for use
  7. * Visit http://www.dynamicdrive.com/ for full source code
  8. ***********************************************/
  9.  
  10. var variableslide=new Array()
  11.  
  12. //variableslide[x]=["path to image", "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)"]
  13.  
  14. variableslide[0]=['images/slide1.jpg', '', '']
  15. variableslide[1]=['images/slide2.jpg', '', '']
  16. variableslide[2]=['images/slide3.jpg', '', '']
  17. variableslide[3]=['images/slide4.jpg', '', '']
  18.  
  19. //configure the below 3 variables to set the dimension/background color of the slideshow
  20.  
  21. var slidewidth='320px' //set to width of LARGEST image in your slideshow
  22. var slideheight='480px' //set to height of LARGEST iamge in your slideshow, plus any text description
  23. var slidebgcolor='#F3F3F3'
  24.  
  25. //configure the below variable to determine the delay between image rotations (in miliseconds)
  26. var slidedelay=3000
  27.  
  28. ////Do not edit pass this line////////////////
  29.  
  30. var ie=document.all
  31. var dom=document.getElementById
  32.  
  33. for (i=0;i<variableslide.length;i++){
  34. var cacheimage=new Image()
  35. cacheimage.src=variableslide[i][0]
  36. }
  37.  
  38. var currentslide=0
  39.  
  40. function rotateimages(){
  41. contentcontainer='<center>'
  42. if (variableslide[currentslide][1]!="")
  43. contentcontainer+='<a href="'+variableslide[currentslide][1]+'">'
  44. contentcontainer+='<img src="'+variableslide[currentslide][0]+'" border="0" vspace="3">'
  45. if (variableslide[currentslide][1]!="")
  46. contentcontainer+='</a>'
  47. contentcontainer+='</center>'
  48. if (variableslide[currentslide][2]!="")
  49. contentcontainer+='</a>'
  50. contentcontainer+='</center>'
  51. if (variableslide[currentslide][3]!="")
  52. contentcontainer+=variableslide[currentslide][3]
  53.  
  54. if (document.layers){
  55. crossrotateobj.document.write(contentcontainer)
  56. crossrotateobj.document.close()
  57. }
  58. else if (ie||dom)
  59. crossrotateobj.innerHTML=contentcontainer
  60. if (currentslide==variableslide.length-1) currentslide=0
  61. else currentslide++
  62. setTimeout("rotateimages()",slidedelay)
  63. }
  64.  
  65. if (ie||dom)
  66. document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')
  67.  
  68. function start_slider(){
  69. crossrotateobj=dom? document.getElementById("slidedom") : ie? document.all.slidedom : document.slidensmain.document.slidenssub
  70. if (document.layers)
  71. document.slidensmain.visibility="show"
  72. rotateimages()
  73. }
  74.  
  75. if (ie||dom)
  76. start_slider()
  77. else if (document.layers)
  78. window.onload=start_slider
  79.  
  80. </script>
  81.  
  82. <ilayer id="slidensmain" width=&{slidewidth}; height=&{slideheight}; bgColor=&{slidebgcolor}; visibility=hide><layer id="slidenssub" width=&{slidewidth}; left=0 top=0></layer></ilayer>
  83.  
  84.     </td>
Feb 16 '12 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
this code is pretty much outdated. document.layers was used back in NN4 (and that was even before Mozilla was founded).
Feb 16 '12 #2

Post your reply

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