Debt Consolidation - Shopping news - Debt Consolidation - Debt Consolidation - French Property

PDA

View Full Version : PLEASE HELP ! Randomizing A Banner Script


locals
Aug 31st 2008, 10:33 pm
Can you please help me make this banner display, display random banners instead of the first banner on the list every time ? THANKS !

var ImageCount = 5; // ***** Change this to the total number of images loaded above ***** //
var ImageDelay = 6000; // ***** Set this to the delay interval desired. 5000 = 5 seconds. //
var LinkTarget = "_self" // ***** Defines where you want linked page to open. _self, _blank, _top, etc //
var ImageIndex = 0; // DO NOT ALTER //
var FirstLoad = 0; // DO NOT ALTER //
var QuickStartID = 0; // DO NOT ALTER //
var htmlString = "" // DO NOT ALTER //

// This function rotates the banner //
function ImageChange()

{

htmlString = '<center>';
htmlString = htmlString + '<font face = "Verdana" size="2">'; // Font and Font Size for caption may be changed here //
htmlString = htmlString +'<a target="_blank"';
htmlString = htmlString + LinkTarget;
htmlString = htmlString + '" href="';
htmlString = htmlString + ImageLoad[ImageIndex][0];
htmlString = htmlString + '"><img border="0" src="'; // Image border size may be changed here //
htmlString = htmlString + ImageLoad[ImageIndex][1];
htmlString = htmlString + '"></a><br>';
htmlString = htmlString + ImageLoad[ImageIndex][2];
htmlString = htmlString + '</font>';
htmlString = htmlString + '</center>';

document.getElementById('MagicImage').innerHTML = htmlString;

if(ImageIndex == ImageCount - 1) // This statement increments image displayed and resets if displaying last image //
{
ImageIndex= 0;
}
else
{
ImageIndex++;
}

if(FirstLoad == 0) // Determins if this is the first time function has run. //
{
SlowFinish();
}

}
// End Funtion //

// This function ensures first banner is displayted without a delay //
function QuickStart()
{
QuickStartID=setInterval("ImageChange()", 1000);
}
// End Funtion //

// This function sets display rate to user defined speed //
function SlowFinish()
{
clearInterval(QuickStartID);
FirstLoad = 1;
setInterval("ImageChange()", ImageDelay);
}
// End Funtion //

QuickStart()

Daemn
Sep 4th 2008, 7:24 am
http://www.php.net/rand

locals
Sep 4th 2008, 9:10 pm
just out of curitosity how does installing the random number code into this script prevent hackers ? and where do i place this ?

my hosting company said some one somehow downloaded "malicious files" to my server ???

temp2
Sep 5th 2008, 6:09 pm
you should view & use these scripts: Random Ads (http://javascriptbank.com/javascript/image/random-ads/detail/), Random Background Image onLoad (http://javascriptbank.com/javascript/background/random-background-image-onload/detail/), Random background-image (http://javascriptbank.com/javascript/background/random-background-image/detail/) and more random image JavaScript (http://javascriptbank.com/title=random)

locals
Sep 5th 2008, 8:52 pm
i will check out these sites THANKS FOR YOUR HELP !

TKY_Publishing
Oct 24th 2009, 2:45 pm
This SHOULD be what you're looking for;



var ImageCount = 6; // ***** Change this to the total number of images loaded above ***** //
var ImageDelay = 7000; // ***** Set this to the delay interval desired. 5000 = 5 seconds. //
var LinkTarget = "_blank" // ***** Defines where you want linked page to open. _self, _blank, _top, etc //
var ImageIndex = 0; // DO NOT ALTER //
var FirstLoad = 0; // DO NOT ALTER //
var QuickStartID = 0; // DO NOT ALTER //
var htmlString = "" // DO NOT ALTER //
var randomnumber = 0; // DO NOT ALTER //

// This function rotates the banner //
function ImageChange()

{

htmlString = '<center>';
htmlString = htmlString + '<font face = "Verdana" size="3">'; // Font and Font Size for caption may be changed here //
htmlString = htmlString +'<a target="';
htmlString = htmlString + LinkTarget;
htmlString = htmlString + '" href="';
htmlString = htmlString + ImageLoad[ImageIndex][0];
htmlString = htmlString + '"><img border="0" src="'; // Image border size may be changed here //
htmlString = htmlString + ImageLoad[ImageIndex][1];
htmlString = htmlString + '"></a><br>';
htmlString = htmlString + ImageLoad[ImageIndex][2];
htmlString = htmlString + '</font>';
htmlString = htmlString + '</center>';

document.getElementById('MagicImage').innerHTML = htmlString;

ImageIndex = Math.floor(Math.random()*ImageCount);

if(FirstLoad == 0) // Determins if this is the first time function has run. //
{
SlowFinish();
}

}
// End Funtion //

// This function ensures first banner is displayted without a delay //
function QuickStart()
{
QuickStartID=setInterval("ImageChange()", 1000);
}
// End Funtion //

// This function sets display rate to user defined speed //
function SlowFinish()
{
clearInterval(QuickStartID);
FirstLoad = 1;
setInterval("ImageChange()", ImageDelay);
}
// End Funtion //

QuickStart()


Magic Image has since come out with a randomized script and I just got that yesterday - and if you could be so kind as to let me know if there is a way that I could hook this up with buttons (so the ss can advance/go to previous) - having a hard time figuring out what the placement is for;


<script type="javascript/text">
<!-- Hide from old browsers
function goHist(a)
{
history.go(a);
}
// -->
</script>
<FORM METHOD="post">
<INPUT TYPE="button" VALUE=" BACK " onClick="goHist(-1)">
<INPUT TYPE="button" VALUE="FORWARD" onClick="goHist(1)">
</form>


Otherwise, I suspect that I'll have to go up a notch and start messin' with jQuery ("Easy Slider" 1.5) or that
jClicker thing (I don't know......:lol:).

I just caught that reference to the fact that someone loaded your server with malicious files, so I think I'm going to be going with either the Easy Slider or jClicker - for the inbuilt security measures - investigate those 2, won't you? Hope this helped you.

dimitar christoff
Oct 25th 2009, 3:58 pm
it's none of my business but this question is an year and a half old, i am sure your help is appreciated nonetheless :D

locals
Oct 25th 2009, 6:41 pm
it actually was VERY MUCH appreciated !

also mods go around and give out infractions for things like that, but it still helped me because in a year and a half NO ONE ELSE ANSWERED IT LOL

see you guys later.