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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    is this easy to make ?

    I'm looking for a banner rotater of my own, in any lanugage, CGI/PHP/JAVA script...

    i just need it to change banners if someone refreshes the screen, and then a new banner is there

    also to be able to edit the size of the banner,


    I dont knwo if this is easy or not to mak e,,


    Thanks for your help

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah! It's very easy! you have to make a random function that generates some numbers and based on those numbers, you can change your banners onload. let's say you have 3 images with the follwoing dimensions:


    Name : Image1.jpg , Dim = 100px * 100px
    Name : Image2.jpg , Dim = 132px * 58px
    Name : Image3.jpg , Dim = 58px * 73px


    we write:


    <html>
    <script>
    function Init()
    {
    ourRand = Math.floor(Math.random() * 3);
    switch ( ourRand )
    {
    case 0 :
    document.getElementById('ourIMG').innerHTML =
    "<img src='Image1.jpg' width='100' height='100'>";
    case 1 :
    document.getElementById('ourIMG').innerHTML =
    "<img src='Image2.jpg' width='132' height='58'>";
    case 2 :
    document.getElementById('ourIMG').innerHTML =
    "<img src='Image3.jpg' width='58' height='73'>";
    }
    }
    </script>
    <body onload = "Init()">
    <div id="ourIMG">
    &nbsp;
    </div>
    </body>




    I didn't test what I wrote, but it has to work!

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That won't work cross-browser - but you can use the same kind of randomness to simply document.write a banner on the page each time.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankx for the code.


    whammy u said it work cross-browser , what do u mean by that ??

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is a link to JavaScriptkits Free Script section and a Random Banner script:
    http://www.wsabstract.com/script/cut149.shtml

    This should work in all browsers. The previous script would only work in IE5 and NS6 and above.

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just a question, you said that my code doesn't work in IE5- and NS6- and I admit, but just imagine that he/she wanted to write a code that changes an element of the page, let's say in a kinda period, WITHOUT reloading the whole page, what I'm asking is that is there a way to do this without using "innerHTML" or "nodeValue"? document.write works fine if you wana put something in the page and do not change it, but what if...

  • #7
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    you use the image.src and link.href properties. both are read/write. i've written this same kind of script, using both of those. my technique was to set up a 2d array of image urls and link urls, pick a random number, stick it in the array, and then use array[random][0] and array[random][1] to set the picture and link. if you do a search in the old forum, you'll find it once or twice.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

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