Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ad rotator javascript

    I've gotten an ad rotator script from a website, but after filling in all the required lines with my URLs, I get an error when trying to view the page some times. Here's what the error says, "A Runtime Error has occurred. Do you wish to Debug? Line: 55 Error: Expected ';'". So there seems to be an error on line 55 - can someone figure out what it is, please?.. Here's the script for you all (with my URLs in it):



    <SCRIPT>

    // put info for randomly selected banners here, as in the examples

    gfx0="http://rcm-images.amazon.com/images/G/01/associates/promotions/b1c-468x60.gif";

    lnk0="http://www.amazon.com/exec/obidos/redirect?tag=mgsonline-20&creative=92489&camp=8117&link_code=dl1&path=subst/misc/amazon-cobrand-cc/v3/marketing-from-associates-step1.html/ref%3Db1_assoc_26";

    alt0="Amazon.com Platinum Visa Card";

    gfx1="http://www.mgsonline.net/home-banner-468x60.gif";

    lnk1="http://www.amazon.com/exec/obidos/redirect-home/mgsonline-20";

    alt1="In Association with Amazon.com";

    gfx2="http://www.cafepress.com/cp/banners/cp_referral_468x60.gif";

    lnk2="http://www.cafepress.com/cp/info/storeref.aspx?refby=mgsonline";

    alt2="Design and Sell Merchandise Online for Free";

    gfx3="http://www.alienware.com/affiliate_pages/banners/gaming_pc_banner_468x60.gif";

    lnk3="http://www.alienware.com/index.aspx?from=_R__Y__A__N_:gaming_pc_banner_468x60";

    alt3="Alienware - Gaming PC for PC Gaming";

    len=4; // change to equal number of banners

    today=new Date();

    today=today.getTime()/10;

    rnd=today%len;

    document.writeln('<A HREF="'+eval("lnk"+rnd)+'"><IMG SRC="'+eval("gfx"+rnd)+'" ALT="'+eval("alt"+rnd)+'" WIDTH="468" HEIGHT="60"></A>');

    </SCRIPT>

    Line 55 (of the HTML document) is, by the way, the line that begins with, "document.writeln". See any problems in that line? Help would be greatly appreciated!

    Thanks in advance,

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <SCRIPT> 
    
    // put info for randomly selected banners here, as in the examples 
    len=4; 
    
    gfx=new Array(len);
    lnk=new Array(len);
    alt=new Array(len);
    
    gfx[0]="http://rcm-images.amazon.com/images/G/01/associates/promotions/b1c-468x60.gif"; 
    lnk[0]="http://www.amazon.com/exec/obidos/redirect?tag=mgsonline-20&creative=92489&camp=8117&link_code=dl1&path=subst/misc/amazon-cobrand-cc/v3/marketing-from-associates-step1.html/ref%3Db1_assoc_26"; 
    alt[0]="Amazon.com Platinum Visa Card"; 
    
    gfx[1]="http://www.mgsonline.net/home-banner-468x60.gif"; 
    lnk[1]="http://www.amazon.com/exec/obidos/redirect-home/mgsonline-20"; 
    alt[1]="In Association with Amazon.com"; 
    
    gfx[2]="http://www.cafepress.com/cp/banners/cp_referral_468x60.gif"; 
    lnk[2]="http://www.cafepress.com/cp/info/storeref.aspx?refby=mgsonline"; 
    alt[2]="Design and Sell Merchandise Online for Free"; 
    
    gfx[3]="http://www.alienware.com/affiliate_pages/banners/gaming_pc_banner_468x60.gif"; 
    lnk[3]="http://www.alienware.com/index.aspx?from=_R__Y__A__N_:gaming_pc_banner_468x60"; 
    alt[3]="Alienware - Gaming PC for PC Gaming"; 
    
    
    
    today=new Date(); 
    
    today=today.getTime()/10; 
    
    rnd=Math.floor(today%len); 
    
    document.writeln('<A HREF="'+lnk[rnd]+'"><IMG SRC="'+gfx[rnd]+'" ALT="'+alt[rnd]+'" WIDTH="468" HEIGHT="60"></A>'); 
    </SCRIPT>

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works perfectly - thanks! There's only one thing that I don't like about it, and that is that it puts a big blue border around the images, whereas a different script I found (one that does not allow the description text, unfortunately) does not do so.. Maybe I can get rid of it some how..

    Well, thanks again!

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No need to alter the script for that. Use CSS - that's what it's for.

    Code:
    <style type="text/css">
    a img { /* any image that's inside an anchor tag */
        border: 0 none;
    }
    </style>
    See how much easier?


  •  

    Posting Permissions

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