|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
New banner when refresh site
We can say i have 3 banners i and i have a html for every banner so they link to someones site.
How do i do to but all banner at one place but you can only se one banner on my site. Then when you refresh my site you se another banner there. Hope you understand my bad english |
|
#2
|
||||
|
||||
|
Generate a random number and display banner based on that.
maybe have the 3 banners called the same with a diff. ending, ie, banner_1, banner_2, banner_3 etc HTML Code:
<script language = "JavaScript"> function DisplayBanner() { var banner = "banner_" + String(Math.floor(Math.random()*3)+1)); Whatever code you use to display bannner can go here... . . . } </script> |
|
#3
|
|||
|
|||
|
I dont really understand what you mena with that.
I have ex thiis code: HTML Code:
<a href= "http://www.fuska.nu" target="_top"> <img src= "http://www.fuska.nu/v3/bilder/banner88x31.gif" height="31" width="88" border="0"></a> HTML Code:
<script language="JavaScript" src="http://www.fuska.se/banner/88x31x1"></script> |
|
#4
|
||||
|
||||
|
instead of:
HTML Code:
<img src= "http://www.fuska.nu/v3/bilder/banner88x31.gif" height="31" width="88" border="0">
HTML Code:
<script language = "JavaScript"> var banner = "banner_" + String(Math.floor(Math.random()*3)+1)); if (banner==1) document.write('<img src= "http://www.fuska.nu/v3/bilder/bannera.gif" height="31" width="88" border="0">'); else if (banner==2) document.write('<img src= "http://www.fuska.nu/v3/bilder/bannerb.gif" height="31" width="88" border="0">'); else if (banner==3) document.write('<img src= "http://www.fuska.nu/v3/bilder/bannerc.gif" height="31" width="88" border="0">'); </script> |
|
#5
|
|||
|
|||
|
doesnt work
|
|
#6
|
||||
|
||||
|
HTML Code:
<script language="javascript"> var banner = Math.floor((Math.random()*3)+1); if (banner==1){ document.write('<img src= "images/Blue hills.jpg" height="31" width="88" border="0">'); } else if (banner==2){ document.write('<img src= "images/Sample_Pic_07.jpg" height="31" width="88" border="0">'); } else if (banner==3){ document.write('<img src= "images/Sample_Pic_06.jpg" height="31" width="88" border="0">'); } </script> |
|
#7
|
|||
|
|||
|
Even if it do work i dont want to download banners to my computer .
|
|
#8
|
||||
|
||||
|
I NEVER SAID YOU DID. JUST REPLACE THE BITS WHERE I HAVE A LINK TO A JPG TO WHATEVER YOU WANT.
LIKE http://www.fuska.nu/v3/bilder/banner88x31.gif. OR HAVE IT WRITE OUT <script language="JavaScript" src="http://www.fuska.se/banner/88x31x1"></script> IF YOU WANT. JUST FOR EACH LINK OR BANNER OR WHATEVER IT IS YOU WANT DIFFERENT EACH TIME USERS REFRESH DO : if (banner==1){ document.write('ANYTHING YOU WANT'); } WHERE 1 IS JUST OPTION. YOU CAN HAVE AS MANY OF THESE AS YOU WANT, JUST CHANGE THE 3 IN Math.floor((Math.random()*3)+1); TO THE NUMBER OF OPTIONS. |
|
#9
|
|||
|
|||
|
You dont have to be angry, i am a noob on this.
Edit: it works! tx ! Last edited by Hedning; 07-23-2006 at 01:22 PM. |
|
#10
|
||||
|
||||
|
sorry, caps lock on... also a noob..
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|