Results 1 to 7 of 7

Thread: Need Help to Modify "Typing Scroller" script!

  1. #1
    Join Date
    Apr 2009
    Posts
    14
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Need Help to Modify "Typing Scroller" script!

    1) Script Title: Typing Scroller

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...typescroll.htm

    3) Describe problem:

    Hi there, I just want to know how I can define a particular color for each line in this script?
    I tried this but unfortunately the font tag does not parse correctly.

    line[1]="<font style='color: red'> This is an awsome script</font>"
    Last edited by Manhattan; 05-19-2010 at 04:54 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Try span tags instead - you might have to escaped the apostrophes too:

    line[1]="<span style=\'color: red\'> This is an awsome script</span>"

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    Manhattan (05-19-2010)

  4. #3
    Join Date
    Apr 2009
    Posts
    14
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Thanks, but it didn't help, tags are typed as well as the phrase!!

  5. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    The scroller is actually shown inside a FORM INPUT element, so you can't simply change the font color by surrounding each text with a colored SPAN element, for example. Are you asking how to change the color individually for each message, or just the color of the scroller in general? The later is easy to do, just edit the line below:

    Code:
    document.write('  style="background-color: '+document.bgColor+'; color: '+document.body.text+'; font-family: verdana; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">')
    Replace the code in red with the desired color name, surrounded in quotes, such as 'blue'.
    DD Admin

  6. The Following User Says Thank You to ddadmin For This Useful Post:

    Manhattan (05-20-2010)

  7. #5
    Join Date
    Apr 2009
    Posts
    14
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Thanks, yeah, I wanna change the color individually for each message.

  8. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ok, try the below modified script:

    Code:
    <script language="JavaScript1.2">
    <!--
    
    /*
    Typing Scroller
    Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
    With modifications by Dynamicdrive.com
    For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
    */
    
    //Secify scroller contents
    var line=new Array()
    line[1]="This is an awsome script"
    line[2]="It brings up the text you want..."
    line[3]="One letter at a time"
    line[4]="You can add and subtract lines as you like."
    line[5]="It\'s very cool and easy to use"
    
    //Specify font size for scoller
    var ts_fontsize="16px"
    
    var scrollercolors=[
    "red",
    "blue",
    "green",
    "black",
    "brown"
    ]
    
    //--Don't edit below this line
    
    var longestmessage=1
    for (i=2;i<line.length;i++){
    if (line[i].length>line[longestmessage].length)
    longestmessage=i
    }
    
    //Auto set scroller width
    var tscroller_width=line[longestmessage].length
    
    lines=line.length-1 //--Number of lines
    
    //if IE 4+ or NS6
    if (document.all||document.getElementById){
    document.write('<form name="bannerform">')
    document.write('<input type="text" name="banner" size="'+tscroller_width+'"')
    document.write('  style="background-color: '+document.bgColor+'; color: '+document.body.text+'; font-family: verdana; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">')
    document.write('</form>')
    }
    
    temp=""
    nextchar=-1;
    nextline=1;
    cursor="\\"
    function animate(){
    if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){
    nextline++;
    nextchar=-1;
    document.bannerform.banner.value=temp;
    temp="";
    setTimeout("nextstep()",1000)}
    else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){
    nextline=1;
    nextchar=-1;
    document.bannerform.banner.value=temp;
    temp="";
    setTimeout("nextstep()",1000)}
    else{
    nextstep()}}
    
    function nextstep(){
    if (cursor=="\\"){
    cursor="|"}
    else if (cursor=="|"){
    cursor="/"}
    else if (cursor=="/"){
    cursor="-"}
    else if (cursor=="-"){
    cursor="\\"}
    document.bannerform.banner.style.color=scrollercolors[nextline-1]
    
    nextchar++;
    temp+=line[nextline].charAt(nextchar);
    document.bannerform.banner.value=temp+cursor
    setTimeout("animate()",25)}
    
    //if IE 4+ or NS6
    if (document.all||document.getElementById)
    window.onload=animate
    // -->
    </script>

    Edit the array in red with the desired colors. The number of colors defined should equal the number of messages you have.
    DD Admin

  9. The Following User Says Thank You to ddadmin For This Useful Post:

    Manhattan (05-21-2010)

  10. #7
    Join Date
    Apr 2009
    Posts
    14
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much ddadmin, it works like a charm!

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
  •