The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

How to do this code to display two banners to each other?

Page 2 of 2 Previous  1, 2

View previous topic View next topic Go down

Solved How to do this code to display two banners to each other?

Post by smurfavr on October 21st 2015, 5:11 am

First topic message reminder :

How to do this code to display two banners to each other?




Code:
<div align="center">
                                   <script language="JavaScript">
<!--
function random_imglink(){
var myimages=new Array()

myimages[1]="http://i39.servimg.com"
myimages[2]="http://i38.servimg.com"
myimages[3]="http://i21.servimg.com"
myimages[4]="http://i58.servimg.com"
myimages[5]="http://i58.servimg.com"
myimages[6]="http://i19.servimg.com"
myimages[7]="http://i21.servimg.com"

var imagelinks=new Array()
imagelinks[1]="http://xxxxxxx"
imagelinks[2]="http://xxxxxxx"
imagelinks[3]="http://xxxxxxx"
imagelinks[4]="http://xxxxxxx"
imagelinks[5]="http://xxxxxxx"
imagelinks[6]="http://xxxxxxx"
imagelinks[7]="http://xxxxxxx"



var ry=Math.floor(Math.random()*myimages.length)

if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+' target="_blank"><img src="'+myimages[ry]+'" border=0></a>')
}

random_imglink()
//-->
</script>
</div>


Last edited by smurfavr on October 26th 2015, 3:46 pm; edited 1 time in total

smurfavr
Active Poster

Male Posts : 1417
Reputation : 12
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down


Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on October 26th 2015, 2:32 pm

You forgot to add that.
Can you do it by clicking the banner to open a new page.

How many banners can be added to this code?
I want to put 8-10 banner.

smurfavr
Active Poster

Male Posts : 1417
Reputation : 12
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on October 26th 2015, 2:55 pm

Change the code to this :
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs = [
    'http://smurfa.bulgarianforum.net/',
    'http://smurfa.bulgarianforum.net/'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index],
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '" target="_blank"><img src="' + img + '"/></a>';
  };
 
  document.write('<div id="randomBanner">' + _randomImage() + _randomImage() + '</div>');
}());</script>
This way the links will open in a new tab.

2 images will display at once, and you can have as many images + links in the code as you want.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on October 26th 2015, 3:46 pm

Now everything works. Thank you Ange Tuteur.

smurfavr
Active Poster

Male Posts : 1417
Reputation : 12
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on October 26th 2015, 3:53 pm

You're welcome ^^

Topic archived

Have a good day. Smile

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Page 2 of 2 Previous  1, 2

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum