PDA

View Full Version : Script not working on IE or Edge, but works in Chrome and Firefox



dlrobioh
11-16-2018, 08:19 PM
1) Script Title: randompic.js

2) Script URL (on DD): This is from a third party that used a DD script but I don't know the URL

3) Describe problem: Script is below. As I put in the title - not working in IE or Edge, but works in Chrome and Firefox. My system is windows10 pro with ie11, Edge 25.10586.0

picList = new Array(
"images/banner/Specials2.jpg",
"images/banner/Specials5.jpg",
"images/banner/Specials3.jpg",
"images/banner/Specials7.jpg",
"images/banner/Specials4.jpg",
"images/banner/Specials1.jpg",
);

altList = new Array(
"Milwaukee Promotion",
"Kenwood Promotion",
"GearWrench Promotion",
"Motorola Promotion",
"3M Promotion",
"3M Fall Protection Promotion",
);

linkList = new Array(
"content/Milwaukee%20P4%202018.pdf",
"content/Kenwood%20Q4%202018.pdf",
"content/GearWrench%20Q3%202018.pdf",
"content/Motorola%20Q3%202018.pdf",
"http://samples.zift123.com/?aa=3m.ziftsolutions.com&wid=ff80818164821e2601648ae643501315",
"content/3M%20Q2%202018.pdf",
);


imgCt = picList.length;

function choosePic() {
if (document.images) {
// choose first pic randomly
randomNum = Math.floor((Math.random() * imgCt));
document.randPic.src = picList[randomNum];
document.randPic.alt = altList[randomNum];

// rotate pic every 20 seconds
setTimeout("choosePic()", 5 * 1000);
}
}

//Fade-in image slideshow- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var slideshow_width='292px' //SET IMAGE WIDTH
var slideshow_height='380px' //SET IMAGE HEIGHT
var pause=5000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)

////NO need to edit beyond here/////////////

var preloadedimages=new Array()
for (p=0;p<picList.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=picList[p]
}

var ie4=document.all
var dom=document.getElementById

if (ie4||dom)
document.write('<div style="position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden"><div id="canvas0" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div></div>')
else
document.write('<a title="'+altList[0]+'" target="_blank" href=\''+linkList[0]+'\'"><img name="defaultslide" src="'+picList[0]+'" alt="'+altList[0]+'"></a>')

var curpos=10
var degree=10
var curcanvas="canvas0"
var curimageindex=0
var nextimageindex=1


function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/100
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<a title="'+altList[nextimageindex]+'" target="_blank" href=\''+linkList[nextimageindex]+'\'"><img src="'+picList[nextimageindex]+'" alt="'+altList[nextimageindex]+'"></a>'
nextimageindex=(nextimageindex<picList.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
}
}

function rotateimage(){
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
var temp='setInterval("fadepic()",50)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
}
else
document.images.defaultslide.src=picList[curimageindex]
curimageindex=(curimageindex<picList.length-1)? curimageindex+1 : 0
}

function resetit(what){
curpos=10
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
if (crossobj.filters)
crossobj.filters.alpha.opacity=curpos
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=curpos/100
}

function startit(){
var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML='<a title="'+altList[curimageindex]+'" target="_blank" href=\''+linkList[curimageindex]+'\'"><img src="'+picList[curimageindex]+'" alt="'+altList[curimageindex]+'"></a>'
rotateimage()
}

if (ie4||dom)
window.onload=startit
else
setInterval("rotateimage()",pause)

<!-- ************ fade in / out rotation of pictures end ********* -->

dlrobioh
11-26-2018, 08:18 PM
I figured out what was causing the issue.

Extra commas behind the last entry in each of the Lists.