www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 07-23-2006, 04:42 AM
    Hedning Hedning is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 5
    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
    Reply With Quote
      #2  
    Old 07-23-2006, 05:59 AM
    cridley's Avatar
    cridley cridley is offline
    Registered User
     
    Join Date: Jun 2006
    Posts: 381
    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>
    Just an idea to point you in the right direction...
    Reply With Quote
      #3  
    Old 07-23-2006, 06:04 AM
    Hedning Hedning is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 5
    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>
    And
    HTML Code:
    <script language="JavaScript" src="http://www.fuska.se/banner/88x31x1"></script>
    How do i use that in the script you wrote so they chnage place when someone refresh my site.
    Reply With Quote
      #4  
    Old 07-23-2006, 10:48 AM
    cridley's Avatar
    cridley cridley is offline
    Registered User
     
    Join Date: Jun 2006
    Posts: 381
    instead of:
    HTML Code:
    <img src= "http://www.fuska.nu/v3/bilder/banner88x31.gif" height="31" width="88" border="0">
    have something like

    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>
    Where bannera.gif, bannerb.gif, and bannerc.gif are your banners...
    Reply With Quote
      #5  
    Old 07-23-2006, 11:21 AM
    Hedning Hedning is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 5
    doesnt work
    Reply With Quote
      #6  
    Old 07-23-2006, 11:52 AM
    cridley's Avatar
    cridley cridley is offline
    Registered User
     
    Join Date: Jun 2006
    Posts: 381
    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>
    Replace my images for your banner images. ADAPT this a bit so it fits your page.
    Reply With Quote
      #7  
    Old 07-23-2006, 12:11 PM
    Hedning Hedning is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 5
    Even if it do work i dont want to download banners to my computer .
    Reply With Quote
      #8  
    Old 07-23-2006, 12:19 PM
    cridley's Avatar
    cridley cridley is offline
    Registered User
     
    Join Date: Jun 2006
    Posts: 381
    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.
    Reply With Quote
      #9  
    Old 07-23-2006, 01:12 PM
    Hedning Hedning is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 5
    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.
    Reply With Quote
      #10  
    Old 07-23-2006, 01:14 PM
    cridley's Avatar
    cridley cridley is offline
    Registered User
     
    Join Date: Jun 2006
    Posts: 381
    sorry, caps lock on... also a noob..
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:01 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.