Results 1 to 6 of 6

 

Thread: easy peasy banner rotation script required

  1. #1
    Elaine's Avatar
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Redcar Cleveland North of Leeds
    Posts
    2,564
    Thanks
    120
    Thanked 86 Times in 62 Posts


    forgot to say - free if possible.

    I've tried a few but if something doesn't quite work - then I'm stumped

    need a script - javascript or dhtml - which will rotate 2 banners each with their own url - needs to be pasted into a SSI - which doesn't have <head> or <body> section.

    really need something where I simply paste in the img src and the url - maybe change the number of banners and the frequency - but that's as much as I can do - and with explicit instructions where to paste it.

    thanks
    Elaine - Children's Rooms, Allkids & Toddler Beds
    email: info @ childrens-rooms.co.uk
    01642 440110

    Parent Centre - Parenting Blog

  2. #2
    futureweb's Avatar
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    919
    Thanks
    13
    Thanked 22 Times in 22 Posts
    Code:
    <script language="Javascript">
    
    var currentdate = 0;
    var core = 0;
    
    function initArray() {
    
    this.length = initArray.arguments.length;
      for (var i = 0; i < this.length; i++) {
      this[i] = initArray.arguments[i];
      }
    }
    
    link = new initArray(
    "http://firstlink.com/",
    "http://secondlink.com/",
    "http://thirdlink.com/"
    );
    
    image = new initArray(
    "http://first-image.gif",
    "http://second-image.gif",
    "http://third-image.gif"
    );
    
    text = new initArray(
    "1st alt txt",
    "2nd alt txt",
    "3rd alt txt"
    );
    
    var currentdate = new Date();
    var core = currentdate.getSeconds() % image.length;
    var ranlink  = link[core];
    var ranimage = image[core];
    var rantext  = text[core];
    
    document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');
    
    </SCRIPT>

  3. #3
    Elaine's Avatar
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Redcar Cleveland North of Leeds
    Posts
    2,564
    Thanks
    120
    Thanked 86 Times in 62 Posts
    thanks for that - but even this one is a conundrum!!! - did look at it but -

    what do you do with this bit -

    var currentdate = 0;
    var core = 0;

    function initArray() {

    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
    }

    AND- THIS NEXT BIT - AND WHERE DO YOU PUT IT!!!


    document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');

    </SCRIPT>

    see what I mean - when I say simple - I mean SIMPLE

    but thanks anyway - mucho appreciated.
    Elaine - Children's Rooms, Allkids & Toddler Beds
    email: info @ childrens-rooms.co.uk
    01642 440110

    Parent Centre - Parenting Blog

  4. #4
    futureweb's Avatar
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    919
    Thanks
    13
    Thanked 22 Times in 22 Posts
    Edited because I confused my self with an over explanation. See notes marked //

    don't have to worry about those they are just declaring them as variables they are set later in the code:

    // Here's where the varibles are set further down
    var currentdate = new Date();
    var core = currentdate.getSeconds() % image.length;


    the whole lot stays together as a block you can dump it all in an include file and only need to change the link, image and alt text arrays then put the code or include file where you want the banners displayed.

    // Only input needed here. //
    // Banner Destination links
    link = new initArray(
    "http://firstlink.com/",
    // Destination link 1
    "http://secondlink.com/",
    // Destination link 2
    "http://thirdlink.com/"
    // Destination link 3
    );

    // Banner Image Locations
    image = new initArray(
    "http://first-image.gif",
    // Banner Image Location 1 (goes with link 1)
    "http://second-image.gif",
    // Banner Image Location 2 (goes with link 2)
    "http://third-image.gif"
    // Banner Image Location 3 (goes with link 3)
    );

    // Banner ALT Text
    text = new initArray(
    "1st alt txt",
    // Banner ALT text 1 (with link 1 and image 1)
    "2nd alt txt",
    // Banner ALT text 2 (with link 2 and image 2)
    "3rd alt txt"
    // Banner ALT text 3 (with link 3 and image 3)
    );

    // End Input //

    the arrays are simple I'll use the text one as an example

    text = new initArray(
    "1st alt txt",
    "2nd alt txt",
    "3rd alt txt"
    );

    notethe last line of the array has no comma ("3rd alt txt") lets say we only wanted 2


    it would now look like

    text = new initArray(
    "1st alt txt",
    "2nd alt txt"
    );

    the 3 arrays make up your banner and each matching line in each of the three arrays is a part of the same banner.

    like this :
    Code:
    <a href="link = new initArray"><img src="image = new initArray" alt="text = new initArray" border="0"></a>
    Last edited by futureweb; 07-12-05 at 11:25 PM.

  5. #5
    Elaine's Avatar
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Redcar Cleveland North of Leeds
    Posts
    2,564
    Thanks
    120
    Thanked 86 Times in 62 Posts
    thanks for the help - I've managed to get A banner showing - but it's not rotating

    here's the link

    http://www.allkids.co.uk/banner.shtml

    all the code is underneath the banner - if you've got time

    cheers
    Elaine - Children's Rooms, Allkids & Toddler Beds
    email: info @ childrens-rooms.co.uk
    01642 440110

    Parent Centre - Parenting Blog

  6. #6
    futureweb's Avatar
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    919
    Thanks
    13
    Thanked 22 Times in 22 Posts
    Nearly

    Replace the code you have with this

    Code:
    <script language="Javascript">
    
    var currentdate = 0;
    var core = 0;
    
    function initArray() {
    
    this.length = initArray.arguments.length;
      for (var i = 0; i < this.length; i++) {
      this[i] = initArray.arguments[i];
      }
    }
    
    link = new initArray(
    "http://www.childrens-shopping.co.uk/",
    "http://www.childrens-rooms.co.uk/"
    );
    
    image = new initArray(
    "http://www.allkids.co.uk/newallkidsimages/CSHSLOGODEC05.gif",
    "http://www.allkids.co.uk/newallkidsimages/CRbanneraddecof.gif"
    );
    
    text = new initArray(
    "Children's Hand Painted Bedroom Furniture - with free gift over &#163;500",
    "Children's Beddding, Duvet Cover Sets from &#163;9.99, Free Delivery on Jumbo Wall Stickers, Matching Bedrom Accessores"
    );
    
    var currentdate = new Date();
    var core = currentdate.getSeconds() % image.length;
    var ranlink  = link[core];
    var ranimage = image[core];
    var rantext  = text[core];
    
    document.write('<a href="' +ranlink+ '\" target=\"_blank\"><img src="'+ranimage+'\" border="0" alt="'+rantext+'\"></a>');
    
    </SCRIPT>
    * Tested and working

    The only thing wrong with yours was this Line:
    document.write('<a href="http://www.childrens-shopping.co.uk" ' +ranlink+ '\" target=\"_blank\"><img src="http://www.allkids.co.uk/newallkidsimages/CSHSLOGODEC05.gif"'+ranimage+'\" border="0" alt="text = new initArray"'+rantext+'\"></a>');

    which should be
    document.write('<a href="' +ranlink+ '\" target=\"_blank\"><img src="'+ranimage+'\" border="0" alt="'+rantext+'\"></a>');

    Enjoy



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Javascript enabled Browser check script required
    By DanielCoe in forum Programming
    Replies: 5
    Last Post: 18-11-05, 05:15 PM
  2. Two Easy Peasy Questions about Newsletters
    By lakrasia in forum Affiliate Marketing Lounge
    Replies: 5
    Last Post: 04-10-04, 11:23 PM
  3. Easy Loans banner question
    By PitBoss in forum Affiliate Future
    Replies: 0
    Last Post: 09-08-04, 09:30 AM
  4. Java Script Banner or html banner ?
    By Vrindavan in forum Programming
    Replies: 1
    Last Post: 24-02-04, 12:22 PM
  5. Banner rotation - bizarre behaviour
    By 1Lit com in forum TradeDoubler
    Replies: 3
    Last Post: 27-03-03, 06:11 AM

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2