5visions
asked on
rotating banner - preload images??
Hi ,, I built a page that rotates an array of banners and animates them a little.
It works fine when it's ofline and im taking the images localy but when i try to take it from the web it doesn't work.
I'm attaching the code. thanks!!!
<html>
<head>
<title>Untitled</title>
</head>
<body>
</body>
</html>
<script language="JavaScript">
/////////////start the banner identifier and member are for administration use
banner('1','promo');
function banner(identifier,member){
//array of banners taken online----->
var dropimages=new Array()
dropimages[0]="http://banner.clubdicecasino.com/cgi-bin/banner.cgi?id=N&member="+member+"& profile=cd c468x3";
dropimages[1]="http://crbanner.casinopays.com/cgi-bin/banner.cgi?id=N&member="+member+"& profile=ca r468x3";
dropimages[2]="http://banner.monacogoldcasino.com/cgi-bin/banner.cgi?id=N&member="+member+"& profile=mg 468";
dropimages[3]="http://banner.usacasino.com/cgi-bin/banner.cgi?id=N&member="+member+"& profile=us a468";
dropimages[4]="http://banner.newyorkcasino.com/cgi-bin/banner.cgi?id=N&member="+member+"& profile=ny c468";
//array of banners taken from a local folder (WORKS!!)
var imgarr=new Array()
imgarr[0]="images/CDCen468 71.gif";
imgarr[1]="images/CDCen468 63.gif";
imgarr[2]="images/CDCen468 64.gif";
imgarr[3]="images/CDCen468 65.gif";
imgarr[4]="images/CDCen468 66.gif";
//<!-----array of links to use afor the <a href:</a> ---->
var linksarr=new Array()
linksarr[0]="http://banner.clubdicecasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr ofile=cdc4 68x3";
linksarr[1]="http://crbanner.casinopays.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr ofile=car4 68x3";
linksarr[2]="http://banner.monacogoldcasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr ofile=mg46 8";
linksarr[3]="http://banner.usacasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr ofile=usa4 68";
linksarr[4]="http://banner.newyorkcasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr ofile=nyc4 68";
var preloadedimages=new Array()
for (p=0;p<dropimages.length;p ++){
preloadedimages[p]=new Image()
preloadedimages[p].src=dro pimages[p]
if(preloadedimages[dropima ges.length -1]){
createscrollingdiv('1','46 8','60', preloadedimages, linksarr);
}
}
}
function createscrollingdiv(identif ier,slides how_width, slideshow_ height, arr, links){
i=0;
document.write('<div id=main'+identifier+' style="position:absolute;w idth:'+sli deshow_wid th+';heigh t:'+slides how_height +';overflo w:hidden;> ')
document.write('<div id=bellow'+identifier+' style="position:relative;w idth:'+sli deshow_wid th+';top:0 px;visibil ity:visibl e;z-index: 0;">')
document.write('<a href="http://banner.clubdicecasino.com/cgi-bin/redir.cgi?id=N">')
document.write('<img id=butimg'+identifier+' src="'+arr[i].src+'" ></a></div>');
document.write('<div name=above id=above'+identifier+' style="position:relative;w idth:'+sli deshow_wid th+';top:- '+slidesho w_height+' ;visibilit y:visible; z-index:1" >')
document.write('<a id=abovelink'+identifier+' href=javascript:rotatelink ('+identif ier+')>');
document.write('<img id=aboveimg'+identifier+' src="'+arr[i+1].src+'" ></a>')
document.write('</div>');
document.write("</div>")
////////////////// hidden table containing data/////////////////////
document.write('<table style="visibility:hidden" >')
document.write('<tr>')
for (p=0;p<arr.length;p++){
document.write('<td id=td"'+p+'idnt'+identifie r+'" >'+arr[p].src+'</td>')
document.write('<td id=tdl"'+p+'idnt'+identifi er+'" >'+links[p]+'</td>')
}
document.write('</tr>')
document.write('</table>')
document.write('<input type="hidden" name="currimg'+identifier+ '" id="currimg'+identifier+'" value="1">')
document.write('<input type="hidden" name="imgheight'+identifie r+'" id="imgheight'+identifier+ '" value="'+slideshow_height+ '">')
document.write('<input type="hidden" name="arrlength'+identifie r+'" id="arrlength'+identifier+ '" value="'+arr.length+'">')
scrolltopimage(identifier) ;
////////////////////////EN D hidden table ////////////////////////// /
}
function scrolltopimage(identifier) {///////// /////////f unction that scrolls the top image down to position:0
positioning=document.getEl ementById( 'above'+id entifier);
////////////////////// CHANGEABLE change the integer to manipulate animation speed /////////////////
positioning.style.top=pars eInt(posit ioning.sty le.top)+8;
////////////////////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ///
if(parseInt(positioning.st yle.top)/8 >-1){
positioning.style.top=0;
setTimeout("changeimage("+ identifier +")",3000) ;
}
else if(parseInt(positioning.st yle.top)<- 1){
setTimeout("scrolltopimage ("+identif ier+")",50 );
}
}
//////////////function that changes the top image to the next image in the array and the buttom immage to the last one
function changeimage(identifier){
curr_img=document.getEleme ntById('cu rrimg'+ide ntifier).v alue;
if(parseInt(curr_img)+1==p arseInt(do cument.get ElementByI d('arrleng th'+identi fier).valu e))
curr_img=0;
else
curr_img++;
img=document.getElementByI d('td"'+cu rr_img+'id nt'+identi fier+'"');
nlink=document.getElementB yId('tdl"' +curr_img+ 'idnt'+ide ntifier+'" ');
if(eval(curr_img)>0)
last_img=eval(curr_img)-1;
else
last_img=parseInt(document .getElemen tById('arr length'+id entifier). value)-1;
bimg=document.getElementBy Id('td"'+l ast_img+'i dnt'+ident ifier+'"') ;
document.getElementById('a bove'+iden tifier).st yle.top=(- document.g etElementB yId('imghe ight'+iden tifier).va lue);
document.getElementById('a boveimg'+i dentifier) .src=img.i nnerHTML;
document.getElementById('a bovelink'+ identifier ).src=nlin k.innerHTM L;
document.getElementById('b utimg'+ide ntifier).s rc=bimg.in nerHTML;
document.getElementById('c urrimg'+id entifier). value=curr _img;
uploadedimage=new Image();
uploadedimage.src=img.inne rHTML;
if(uploadedimage){
scrolltopimage(identifier) ;
}
}
function rotatelink(identifier){/// /////// function that opens the linked url (onclick)
indx=parseInt(document.get ElementByI d('currimg '+identifi er).value)
newindow=document.getEleme ntById('td l"'+indx+' idnt'+iden tifier+'"' ).innerHTM L
window.location=newindow;
}
</script>
It works fine when it's ofline and im taking the images localy but when i try to take it from the web it doesn't work.
I'm attaching the code. thanks!!!
<html>
<head>
<title>Untitled</title>
</head>
<body>
</body>
</html>
<script language="JavaScript">
/////////////start the banner identifier and member are for administration use
banner('1','promo');
function banner(identifier,member){
//array of banners taken online----->
var dropimages=new Array()
dropimages[0]="http://banner.clubdicecasino.com/cgi-bin/banner.cgi?id=N&member="+member+"&
dropimages[1]="http://crbanner.casinopays.com/cgi-bin/banner.cgi?id=N&member="+member+"&
dropimages[2]="http://banner.monacogoldcasino.com/cgi-bin/banner.cgi?id=N&member="+member+"&
dropimages[3]="http://banner.usacasino.com/cgi-bin/banner.cgi?id=N&member="+member+"&
dropimages[4]="http://banner.newyorkcasino.com/cgi-bin/banner.cgi?id=N&member="+member+"&
//array of banners taken from a local folder (WORKS!!)
var imgarr=new Array()
imgarr[0]="images/CDCen468
imgarr[1]="images/CDCen468
imgarr[2]="images/CDCen468
imgarr[3]="images/CDCen468
imgarr[4]="images/CDCen468
//<!-----array of links to use afor the <a href:</a> ---->
var linksarr=new Array()
linksarr[0]="http://banner.clubdicecasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr
linksarr[1]="http://crbanner.casinopays.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr
linksarr[2]="http://banner.monacogoldcasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr
linksarr[3]="http://banner.usacasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr
linksarr[4]="http://banner.newyorkcasino.com/cgi-bin/redir.cgi?id=N&member="+member+"&pr
var preloadedimages=new Array()
for (p=0;p<dropimages.length;p
preloadedimages[p]=new Image()
preloadedimages[p].src=dro
if(preloadedimages[dropima
createscrollingdiv('1','46
}
}
}
function createscrollingdiv(identif
i=0;
document.write('<div id=main'+identifier+' style="position:absolute;w
document.write('<div id=bellow'+identifier+' style="position:relative;w
document.write('<a href="http://banner.clubdicecasino.com/cgi-bin/redir.cgi?id=N">')
document.write('<img id=butimg'+identifier+' src="'+arr[i].src+'" ></a></div>');
document.write('<div name=above id=above'+identifier+' style="position:relative;w
document.write('<a id=abovelink'+identifier+'
document.write('<img id=aboveimg'+identifier+' src="'+arr[i+1].src+'" ></a>')
document.write('</div>');
document.write("</div>")
////////////////// hidden table containing data/////////////////////
document.write('<table style="visibility:hidden" >')
document.write('<tr>')
for (p=0;p<arr.length;p++){
document.write('<td id=td"'+p+'idnt'+identifie
document.write('<td id=tdl"'+p+'idnt'+identifi
}
document.write('</tr>')
document.write('</table>')
document.write('<input type="hidden" name="currimg'+identifier+
document.write('<input type="hidden" name="imgheight'+identifie
document.write('<input type="hidden" name="arrlength'+identifie
scrolltopimage(identifier)
////////////////////////EN
}
function scrolltopimage(identifier)
positioning=document.getEl
////////////////////// CHANGEABLE change the integer to manipulate animation speed /////////////////
positioning.style.top=pars
//////////////////////////
if(parseInt(positioning.st
positioning.style.top=0;
setTimeout("changeimage("+
}
else if(parseInt(positioning.st
setTimeout("scrolltopimage
}
}
//////////////function that changes the top image to the next image in the array and the buttom immage to the last one
function changeimage(identifier){
curr_img=document.getEleme
if(parseInt(curr_img)+1==p
curr_img=0;
else
curr_img++;
img=document.getElementByI
nlink=document.getElementB
if(eval(curr_img)>0)
last_img=eval(curr_img)-1;
else
last_img=parseInt(document
bimg=document.getElementBy
document.getElementById('a
document.getElementById('a
document.getElementById('a
document.getElementById('b
document.getElementById('c
uploadedimage=new Image();
uploadedimage.src=img.inne
if(uploadedimage){
scrolltopimage(identifier)
}
}
function rotatelink(identifier){///
indx=parseInt(document.get
newindow=document.getEleme
window.location=newindow;
}
</script>
you need 1 more <IMG stye="display:none>, sorry
crap, I am missing a " as well :-(, you want 5 <IMG stye="display:none"> just after the body tag. ie 5 hidden images the banners are loaded into.
ASKER
thanks but didnt work :-[ ???
ASKER
If you copy and paste the code you can see the problem there , im only guessing that the problem is in the preloader because it worked nicely offline. but maybe its something else.
anyways ive been trying many things with no success. any help would be appreciated ////// thanks!!
anyways ive been trying many things with no success. any help would be appreciated ////// thanks!!
this is weird because I copied te code into my frontpage 2003 and it all worked except one of the images did not load. I think about 4 of them did...i just previed the page...it might be that sometimes the images are not loading fast enought, and you may need to find some way to change an image that did not load...so far I can't find the problem, but I am still looking
looks like when I do this, the middle image is the problem dropimages[2] ..it keeps trying to load a page and not a picture. The other four pictures load fine even without the stuff after the '?'
ASKER
the code is woking but the problem is that its not running smoothly , when i run banners located localy it runs good but when i run banners from the web , some jumping accure and it doesnt look good,, also the banner that doesnt load because its a little larger then the other 4 but my thoughts are that a working preloader would fix that.
When i tried to load each image, the 3rd one loaded a full web page, but it may have been something i did. What you may need to do is to load the images before running the banner. It may be that you need to put in some kind of timer before you start the banner..just a thought...
ASKER
Hi all ,, im willing to add more points if someone can explain how to do it.
I need a working version of the code attached, there is a bug there that i couldnt figure out but i need the code or any simmilar code that does the same effect , takes an array of banners and rotates them in a scroller animation-- it has to be independent so i can build a few rotating banners in one page. Thanks!!!!!
I need a working version of the code attached, there is a bug there that i couldnt figure out but i need the code or any simmilar code that does the same effect , takes an array of banners and rotates them in a scroller animation-- it has to be independent so i can build a few rotating banners in one page. Thanks!!!!!
Your code works fine for me with no problems as long as I change the 3rd image to something else. i just copied the 4th image line into the 3rd one and there are no problems. It looks great too!!
Hi 5visions,
@robotman757 -
"When i tried to load each image, the 3rd one loaded a full web page, but it may have been something i did."
- The web page is set up so if the "member" value in the URL string is not found it will redirect to the web page. If you click here, it will load correctly:
http://banner.monacogoldcasino.com/cgi-bin/banner.cgi?id=N&member=member&profile=mg468
@5visions -
- I'm afraid I have bad news for you, you will absolutely NOT be able to preload these images directly. With the links you have, each site is connecting to a CGI banner rotator itself redirecting to a different banner each time. Because the link is not set directly to an image, it won't preload. If the CGI script were simply spewing out the random image, it would prbably work, but because it redirecting, it will not work to preload using those links.
Don't fear though, I'm working something out for you, so hang tight and I'll get back to you with a solution.
Regards...
ziff...................... .......... .......... .......... .......... ....gone.
@robotman757 -
"When i tried to load each image, the 3rd one loaded a full web page, but it may have been something i did."
- The web page is set up so if the "member" value in the URL string is not found it will redirect to the web page. If you click here, it will load correctly:
http://banner.monacogoldcasino.com/cgi-bin/banner.cgi?id=N&member=member&profile=mg468
@5visions -
- I'm afraid I have bad news for you, you will absolutely NOT be able to preload these images directly. With the links you have, each site is connecting to a CGI banner rotator itself redirecting to a different banner each time. Because the link is not set directly to an image, it won't preload. If the CGI script were simply spewing out the random image, it would prbably work, but because it redirecting, it will not work to preload using those links.
Don't fear though, I'm working something out for you, so hang tight and I'll get back to you with a solution.
Regards...
ziff......................
That's okay..I have a broadband connection and maybe that is why the script was working fine for me once I changed the 3rd picture...I was able to get the 3rd picture to load by plugging in the values correctly, but noticed that the other four did not seem to need any values and just worked correctly. All is well though from what I see...
Hi 5visions,
Alright, having downloaded a bunch of the Casino Banners, I have put together a package for you with a JS file, the Banner Images, and instructions for use. Check out the Example page, and if you like the effect, download the package.
The JS File also contains instructions for setting modifications to your liking. I've used the Affiliate Links you gave in your example above, all you need to do is set your "member" name in the JS File.
http://www.webmastereseller.com/test/rotator/
Hope that helps.
Regards...
Alright, having downloaded a bunch of the Casino Banners, I have put together a package for you with a JS file, the Banner Images, and instructions for use. Check out the Example page, and if you like the effect, download the package.
The JS File also contains instructions for setting modifications to your liking. I've used the Affiliate Links you gave in your example above, all you need to do is set your "member" name in the JS File.
http://www.webmastereseller.com/test/rotator/
Hope that helps.
Regards...
ASKER
Thanks for the code and the explanations,, I understand from the code that you get the images from a local folder:
document.getElementById('b
and the var Banner stands for the path to that folder.
-----what i need to do is to get these banners from the http , I don't have them localy-------------
As for the problem with the preloader i think you are right, it won't preload unless its a .gif , thanks for the help , hope you can make it work for http pathes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var preloadedimages=new Array()
for (p=0;p<dropimages.length;p
preloadedimages[p]=new Image()
preloadedimages[p].src=dro
if(preloadedimages[dropima
createscrollingdiv('1','46
}
}
}
Do this, put these just ater the body tag
<body onload='preloadBans()'>
<IMG stye="display:none><IMG stye="display:none><IMG stye="display:none><IMG stye="display:none>
then have the preload function as
function preloadBans(){
for (i=0;i<5;i++)
document.images[i].src=dro
}