Results 1 to 7 of 7

Thread: Random linked banners (one by one) at each refresh/reload

  1. #1
    Join Date
    Jun 2010
    Posts
    40
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Random linked banners (one by one) at each refresh/reload

    Does anyone know such a script ? I searched but I din't find what I was looking for

    And I don't want to complicate things with hosted files. I want to use this for advertisement on my site.

    Thanks !

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    http://www.dynamicdrive.com/dynamici...nslideshow.htm

    http://www.dynamicdrive.com/dynamici...army/index.htm

    Either of the two above slide show scripts can do linked images. And they can each also be set up in manual mode without controls or descriptions. And they each also have an optional random setting. So it's just a matter of which one you like. As I say, either can be set to show just one image w/link per page load.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2010
    Posts
    40
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thank you for your reply, the code is good, but is there another, one wich I can use directly html codes

    Code:
    <a href="" title=""><img src="" /></a>
    Even javascript. Is there ?

  4. #4
    Join Date
    Jun 2010
    Posts
    40
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Unhappy

    Sorry for the bump but can anyone help me please ?

  5. #5
    Join Date
    Jul 2010
    Location
    Bridport, Dorset
    Posts
    58
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    Hi,
    I do not know of a script whereby you can have all the html on the page and it just chooses one of them to display, I use this one here: www.test.steptoes.co.uk to display different adverts on the left hand side.

    Thats all you need in your body tags..
    Code:
    <script type="text/javascript" src="js/banner.js"></script>
    Thats all you need in the external file.. (js/banner.js)
    Code:
    <!--
    function random_imglink(){
      var myimages=new Array()
      //specify random images below. You can have as many as you wish
      myimages[1]="images/banner/1.jpg"
      myimages[2]="images/banner/2.jpg"
      myimages[3]="images/banner/3.jpg"
      myimages[4]="images/banner/4.jpg"
      myimages[5]="images/banner/5.jpg"
      myimages[6]="images/banner/6.jpg"
    
      //specify corresponding links below
      var imagelinks=new Array()
      imagelinks[1]="/link1.html"
      imagelinks[2]="/link2.html"
      imagelinks[3]="/link3.html"
      imagelinks[4]="/link4.html"
      imagelinks[5]="/link5.html"
      imagelinks[6]="/link6.html"
      var ry=Math.floor(Math.random()*myimages.length)
      if (ry==0)
         ry=1
         document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
    }
      random_imglink()
    //-->
    I think that is pretty easy to use. You can see the HTML the script will write out in the javascript.
    Hope that helps.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You could combine the two -

    banner.js:

    Code:
    function random_imglink(){
    	var myimages = [], ry, lnk;
    	//specify random images below. You can have as many as you wish
    	myimages[0] = "images/banner/1.jpg";
    	myimages[1] = "images/banner/2.jpg";
    	myimages[2] = "images/banner/3.jpg";
    	myimages[3] = "images/banner/4.jpg";
    	myimages[4] = "images/banner/5.jpg";
    	myimages[5] = "images/banner/6.jpg";
    	
    	//specify corresponding links below
    	var imagelinks = [];
    	imagelinks[0] = "/link1.html";
    	imagelinks[1] = "/link2.html";
    	imagelinks[2] = "/link3.html";
    	imagelinks[3] = "/link4.html";
    	imagelinks[4] = "/link5.html";
    	imagelinks[5] = "/link6.html";
    	
    	ry = Math.floor(Math.random() * myimages.length);
    	lnk = document.getElementById('bannerlink');
    	lnk.href = imagelinks[ry];
    	lnk.getElementsByTagName('img')[0].src = myimages[ry];
    }
    random_imglink();
    In the body section where you want the banner to appear:

    Code:
    <a id="bannerlink" href="/link1.html" title=""><img src="images/banner/1.jpg" alt="" /></a>
    <script type="text/javascript" src="js/banner.js"></script>
    Last edited by jscheuer1; 09-02-2010 at 02:44 PM. Reason: simplify
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2010
    Posts
    40
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •