HTML

Ace

Madly Diligent
Joined
Sep 12, 2010
Messages
6,079
Reaction score
0
FP$
6
How do you use HTML to add a banner image that links to a different site that changes all the time? Like the one we have on this forum.
 
Thanks. Feel free to post more.<br /><br />-- 20 Oct 2010, 19:39 --<br /><br />i put this in:
Code:
<div align="center"><script type="text/javascript" language="javascript">function swg_fa_randomads() {var ads = new Array();

// List of banners, first item = banner url, second item = link url
ads[0] = new Array('http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png
', 'http://chatarena.tk');
ads[1] = new Array('http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png
', 'http://chatarena.tk');
ads[2] = new Array('http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png
', 'http://chatarena.tk');

// do not edit
i=Math.floor(Math.random()*ads.length);document.write('<a href="'+ads[i][1]+'" target="_blank"><img src="'+ads[i][0]+'" border="0" width="468" height="60"></a>');} swg_fa_randomads();</SCRIPT>
</DIV>

but the banner don't appear, can some please help me.
 
If your code is like you have it pasted here I'm pretty sure the problem was due to unterminated string literals. This works fine for me.

Code:
<script type="text/javascript" language="javascript">
	(function(){
        var ads = [
            ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'], 
            ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'],
            ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk']
        ];
        
        i=Math.floor(Math.random()*ads.length);
        document.write('<a href="'+ads[i][1]+'" target="_blank"><img src="'+ads[i][0]+'" border="0" width="468" height="60"></a>');
    })();
</script>
 
Well you can use the code I posted which is essentially the code you posted with some minor implementation changes or you can move your closing apostrophes to the end of your strings which should fix the problem if that was indeed the only issue.

Anyway, easy way: just paste in my code instead and see if it does what it is supposed to.
 
I pasted in your code and it worked but when i add more, it stops working. Can you help me?
 
It would help to see your code before I can answer that. But to take a guess, have you made sure that there isn't a comma missing in your array? The last element isn't supposed to have a trailing comma but you have to add one if you add more elements after it.

Code:
var ads = [
      ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'],
      ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'],
      ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'] <--
      ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk'],
      ['http://i24.servimg.com/u/f24/15/74/16/34/coolte10.png', 'http://chatarena.tk']
];
 
The problem is fixed, i missed out the commas. Thanks.
 
Back
Top Bottom