Random HTML, how to do it on website.

flame1117

banned
I wasn't sure if this would be in the "internet" section or not. :/

How do you set-up one of those random html generator things? where you can put in different html codes to show then it picks one at random?

I want to do this with a Affilates part in my website.

I found out how i cna do it in my CPANAL with CGI but i have to save all my html files at shtml, i would rather not do that, is there a way i can get around this?
 
Last edited:
extendcradle said:
There are lots of codes around the net or visit www.planetsourcecode.com and go to javascript section. Easy to copy-and-paste but sometimes hard to memorize.LOL

I cant find anything on there.

Just to clear up what i need, Is i want to put just a code onto a html page. and then on some file it would connect to to somthing, i can have different snippets of code, then it would pick one of the nsippets of html code at random and display it.
 
That wont work at all. For what im doing, i'm going to have different small banners showing for affialtes and im not going to have a list of 20 banners, so I want a different one to show up.


So that wouldn't help at all.
 
Hey does anyone have AIM or anything i can talk to them with, and they can maybe help me with this script(cromewell anychance? since you seem to know what your tlaking about)

I got it to what i thought was working, but it ever change, it just showes up with defualt.jpg everytime. i don't know how to change it to more and others, im confussed and have been messing with it for almost an hour
 
Thank's, im going to go check that out now. I didn't even relize for a while it was suposto roate them in secends, I was looking for one thats just different each page load. but this works too ;) Thanks again.
 
A different one loading every time is relatively easy as well. Just change it to remove the time delay and have it pick a random banner from the array
 
Cromewell said:
A different one loading every time is relatively easy as well. Just change it to remove the time delay and have it pick a random banner from the array

I'll try and figure out how to do that....But I'm not really sure haha.
 
Thanks for all the help cromewell, I think iv'e got it now, I just need to test it, and I'm to lazy to make test banners so i'm just going to wait untill i get the banner, and work on the rest untill then.
 
Hey cromewell, Sorry to ask again..

but could you do an example, where it would just pick a randomm banner at load? and not switch? I got it to so it doesn't just rotate and change, but i dont know how to make it pick a random banner from the array.

Or tell me how to make it pick a random banner from the array.
 
Keeping the same files this will do it. Wait a few seconds between refreshes for it to pick a different banner
Code:
<!--

/*#########################################################################################
  # Author : Khaled Elmougey        Email : [email protected]                      #
  # Website: www.futurecompany.com  Title  : Banner Rotator                               # 
  # Version : 1.0.0   Date : December,25,98                                               #  
  # Version : 1.1.0   Date : Febuaray,17,2000                                             #                                             
  # Bugs   : I did not encounter any.                                                     #
  # compatibility: It has been tested with MSIE 4.0, 5.0 and Netscape 3.0, 4.0, 4.6.      #
  # Copyrights: you can copy and paste it in to your website as along as this copyright   #
  #             is intact, copyrights99,2000 arabflex.com all rights are reserved.        #
  # Comments:                                                                             #
  #    1) do not forget to put the <IMG SRC=""> tags in the body.                         #
  #    2) all images suppose to have the same length and width                            #                                
  #    3)Please do email me for any bugs you encounter.                                   #                                 
  #    4)You can set these variables:                                                     #                                  
  #      a) numberOfBanners: number of banners.                                           #                                  
  #      b) displaytime    : how long the banner will be displayed                        # 
  #      c) getBanner      : name of each banner                                          #
  #      d) getSiteUrl     : The site url, when you click the banner                      #                      
  #      e) imageWidth     : The width of the image                                       #
  #      f) imageHeight    : The height of the image                                      #
  #      g) dir            : the location of the images, if their is no dir leave it as ""#
  #      h) pages          : The pages that a specific banners will be displayed on       #
  #      i) banners0       : The banners that will be displayed on a specific page.       #
  #      j) rotate         : Set it to true to rotate all banners or false to display     #
  #                          a random banner.                                             #
  ##########################################################################################*/

var numberOfBanners = 3;
var pause       = 5000; 
var imageWidth  = 410;
var imageHeight = 40;
var dir         = "";
var rotate      = "false";

var getBanner  = new Array("sillylogo.jpg","sillylogo2.jpg","sillylogo3.jpg");
var getSiteUrl = new Array(numberOfBanners);  
getSiteUrl[0]  = "http://www.computerforum.com/";
getSiteUrl[1]  = "http://www.futureshop.ca";
getSiteUrl[2]  = "http://www.ncix.com";  

var pages   = new Array("blah.htm");

var banners0 = new Array("0","1","2");  
////////////////////////Nothing below this line need to be modified/////////////////////////////

var counter  = 0;
var nBanners = numberOfBanners;
var add      = "";
var b = new Banner(); 
b.desireBanners();

function Banner()
  {
  this.banner  = new Array(nBanners);  
  this.Url     = new Array(nBanners);                      
  this.banners = banners;
  this.address = address;
  this.desireBanners = desireBanners;
  this.setBanners = setBanners;
  }

function banners(tempBanner,i)
  {    
  this.banner[i]     = new Image(imageWidth,imageHeight);                 
  this.banner[i].src = dir + tempBanner; 
  }

function address(getUrl,i) 
  {this.Url[i] = getUrl;}

function desireBanners()
  {
  for (var i = 0; i < numberOfBanners; i++)
     {
     var loc    = location.pathname;
     var length = loc.length;
     var start  = loc.lastIndexOf('/') + 1;
     var desirPage = loc.substring(start,length);
     if (desirPage == pages[i])
       { 
       eval("nBanners = banners" + i +".length");
       for (var j = 0; j < nBanners; j++)
          {
          eval("this.banners(getBanner[banners" + i + "[" + j + "]]," + j + ")");
          eval("this.address(getSiteUrl[banners" + i + "[" + j + "]]," + j + ")");
          }
       return;
       }
     }
  for (var j = 0; j < nBanners; j++)
     {
     this.banners(getBanner[j],j);
     this.address(getSiteUrl[j],j);
     }
  }

function setBanners()  
  {
  document.img.src = this.banner[counter].src;   
  add = this.Url[counter];
  }

function displayBanners()
  {
  if (rotate == "false") {counter = Math.round(Math.random() * (nBanners - 1));}
  b.setBanners();
  if (rotate == "true")
    {
    counter++;                                 
    if (counter > (nBanners - 1)) {counter = 0;}
    setTimeout("displayBanners()",pause);
    }  
  }

function goTo() {document.location.href = add;}

function show() {window.status = add;}
// End -->
 
Back
Top