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
    Jul 2013
    Location
    Manchester UK
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to change Banner Size, Help

    Ok this is a code I put on my header.php age

    it is suppose to change the banner every time the page is refreshed.

    how do I change the size I want it to be 900x120

    This is a temporary link to the website: http://ivgdb.co.uk/padrewa/gallery/index…


    please help

    thanks


    this is the code:


    <SCRIPT LANGUAGE="Javascript">
    function banner() { } ; b = new banner() ; n = 0
    b[n++]= "<A HREF='http://ivgdb.co.uk/padrewa/gallery… ><IMG name=randimg SRC='http://farm3.staticflickr.com/2809/… border='0' ALT='Banner1'></A>"

    b[n++]= "<A HREF='http://ivgdb.co.uk/padrewa/gallery… name=randimg SRC='http://farm8.staticflickr.com/7414/… border='0' ALT='Banner2'></A>"

    b[n++]= "<A HREF='http://ivgdb.co.uk/padrewa/gallery… name=randimg SRC='http://farm8.staticflickr.com/7442/… border='0' ALT='Banner3'></A>"
    i=Math.floor(Math.random() * n) ;
    document.write( b[i] )
    </SCRIPT>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    That's horribly ancient JavaScript code.

    You really need to toss it and start over.

    But in any case, the solution has nothing directly to do with JavaScript, at all.

    You just need to specify the size of the image. The old fashioned way:
    <img width="900" height="120" border="0" ... >
    or the more modern way:
    <img style="width: 900px; height: 120px; border: none;" ... />
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    Come to think of it... This is NUTSO!

    Since this is a PHP page, do *NOT* do this with JavaScript! Especially completely obsolete JavaScript.

    Do it in your PHP code. Makes much more sense.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    But if you won't change to doing it in PHP (you really should) at least do this:

    First, replace the existing <script>...</script> that creates the banner with just this code:
    Code:
    <a href="http://padrewa.com"><img id="mybanner" style="height: 120px; width: 900px; border: none;" alt="Banner"/></a>
    That's right. No scripting there, at all. Just HTML.

    And then, at the *bottom* of your page, JUST before the </body> tag, put in this code:
    Code:
    <script type="text/javascript">
    (
      function() 
      {
          var pix = [
               "2809/9260726313_d10047a325_o.jpg",
               "7414/9260729041_dd5c3223fb_o.jpg",
               "7442/9263509688_6ddc14761f_o.jpg"
          ]
          document.getElementById("mybanner").src = 
              "http://farm3.staticflickr.com/" + pix[Math.floor(Math.random()*pix.length)];
      }
    )();
    </script>
    Yes, I tested it. Yes, it works.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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