SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    cd /pub; more beer diacono's Avatar
    Join Date
    Dec 2000
    Location
    Horsham, West Sussex, UK
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not fluent in js, i just tinker around, copying changing and sometimes make som scripts better!

    but i've tried with this and just cant, how do i make this random??

    Code:
    <script language="JavaScript1.2">
    
    /*
    Fading Ticker Tape Script-
    */
    //default speed is 4.5 seconds, Change that as desired
    var speed=8000
    
    var news=new Array()
    news[0]="1st text"
    news[1]="2nd text"
    news[2]="3rd text"
    
    i=0
    if (document.all)
    tickerobject=document.all.subtickertape.style
    else
    tickerobject=document.tickertape.document
    function regenerate(){
    window.location.reload()
    }
    function regenerate2(){
    if (document.layers)
    setTimeout("window.onresize=regenerate",450)
    }
    
    function update(){
    BgFade(0xff,0xff,0xff, 0x00,0x00,0x00,30);
    if (document.layers){
    document.tickertape.document.subtickertape.document.write('<span class="subtickertapefont">'+news[i]+'</span>')
    document.tickertape.document.subtickertape.document.close()
    }
    else
    document.all.subtickertape.innerHTML=news[i]
    
    if (i<news.length-1)
    i++
    else
    i=0
    setTimeout("update()",speed)
    }
    
    function BgFade(red1, grn1, blu1, red2,
    grn2, blu2, steps) {
    sred = red1; sgrn = grn1; sblu = blu1;
    ered = red2; egrn = grn2; eblu = blu2;
    inc = steps;
    step = 0;
    RunFader();
    }
    function RunFader() {
    var epct = step/inc;
    var spct = 1 - epct;
    if (document.layers)
    tickerobject.bgColor =
    Math.floor(sred * spct + ered *
    epct)*256*256 +
    Math.floor(sgrn * spct + egrn * epct)*256 +
    Math.floor(sblu * spct + eblu * epct);
    else
    tickerobject.backgroundColor=
    Math.floor(sred * spct + ered *
    epct)*256*256 +
    Math.floor(sgrn * spct + egrn * epct)*256 +
    Math.floor(sblu * spct + eblu * epct);
    if ( step < inc ) {
    setTimeout('RunFader()',1);
    }
    step++;
    }
    
    </script>
    you can find a working one here at the bottom or better here

    thanx


  2. #2
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello diacono,

    I've moved your post to Client Side Scripting (Javascript) to help give you a better answer on randomizing your ticker tape script.

    I'm sure our javascript gurus will help you find the answer you're looking for.

    Sherice Jacob - Web Improvement Expert
    Improve Website Conversions | eBook Covers
    Follow Me on Twitter!


Bookmarks

Posting Permissions

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