Results 1 to 9 of 9

Thread: Repeating Flying Letters

  1. #1
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Repeating Flying Letters

    Flying Letters

    Hi

    Please, how do I make that script keep repeating? Currently it does 1 cycle then stops until the page is revisited or refreshed. If possible, I'd like it to repeat every 9 seconds. Im not really a coder but I can follow instructions such as FIND 'code..' ADD, CHANGE etc.

    Any help appreciated. Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's some ugly code ye got thar, sonny-Jim.
    Code:
    <h2><span id="fly"></span></h2>
    
    <script type="text/javascript">
    window.onerror=new Function("return true");
    
    //Flying Letters script- by Matthias (info@freejavascripts.f2s.com)
    //For this script and more, visit http://www.dynamicdrive.com
    
    //Configure message to display. Use "$" for linebreak
    message = "Thanks for visiting Dynamic Drive!" // $ = taking a new line
    distance = 50 // pixel(s)
    speed = 100 // milliseconds
    interval = 5;        // Seconds to wait between running
    
    if (!document.all)
    document.write('<h2>'+message+'</h2>')
    
    </script>
    
    <script language="JavaScript1.2">
    
    txt="";
    num=0;
    num4=0;
    flyofle="";
    flyofwi="";
    flyofto="";
    
    function start() {
      txt="";
      num=0;
      num4=0;
      flyofle="";
      flyofwi="";
      flyofto="";
      stfly();
      setTimeout("start()", interval * 1000);
    }
    
    function stfly() {
      for(i=0;i != message.length;i++) {
        if(message.charAt(i) != "$") {
          txt+="<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"<\/span>";
        } else {
          txt+="<br>";
        }
      }
      fly.innerHTML=txt;
      txt="";
      flyofle=fly.offsetLeft;
      flyofwi=fly.offsetWidth;
      flyofto=fly.offsetTop;
      fly2b();
    }
    
    function fly2b(){
      if(num4 != message.length){
        if(message.charAt(num4) != "$") {
          eval("n"+num4+".style.left=flyofle-n"+num4+".offsetLeft+flyofwi/2");
          eval("n"+num4+".style.top=flyofto-n"+num4+".offsetTop+distance");
          eval("fly3('n"+num4+"',eval(n"+num4+".style.left.substring(0,n"+num4+".style.left.length-2)),(eval(n"+num4+".style.left.substring(0,n"+num4+".style.left.length-2))/5),eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2)),(eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2))/5))");
        }
        num4++;
        setTimeout("fly2b()",speed);
      }
    }
    function fly3(target,lef2,num2,top2,num3){
      if((Math.floor(top2) != 0 && Math.floor(top2) != -1) || (Math.floor(lef2) != 0 && Math.floor(lef2) != -1)) {
        if(eval("'"+lef2+"'").charAt(0) != '-'){
          lef2=lef2-num2
        } else {
          lef2+=(-num2)
        }
        if(Math.floor(lef2) != -1) { 
          eval(target+".style.visibility='visible';"+target+".style.left=Math.floor(lef2)");
        } else { 
          eval(target+".style.visibility='visible';"+target+".style.left=Math.floor(lef2+1)");
        }
        if(eval("'"+lef2+"'").charAt(0) != '-') {
          top2=top2-num3
        } else {
          top2=top2+(-num3);
        }
        if(Math.floor(top2) != -1){
          eval(target+".style.top=Math.floor(top2)");
        } else {
          eval(target+".style.top=Math.floor(top2+1)");
        }
        setTimeout("fly3('"+target+"',"+lef2+","+num2+","+top2+","+num3+")",50);
      }
    }
    
    // stfly();
    
    start();
    </script>
    That looks a lot better.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Twey...appreciated.

  4. #4
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi all

    Im thinking it would be cool if the text generated by 'flying letters' could be url clickable. Is there a way to make the text double as a link also?

    Any help appreciated. Thanks

  5. #5
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, so I take it this can not be done? Ah well.

    Cool script anyhow.

    Thanks again,
    Net.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, certainly. Just put the HTML in the message string.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm

    like you said I tried inserting html into message string. Yet all i get is the html coming up in the same way as the message
    im doing:

    Code:
    message = "<a href=index.php>Thanks for visiting Dynamic Drive!</a>"
    I suppose im inserting it wrong! any ideas please?

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It cannot be done simply by inserting HTML because the script carves up the message string and serves it as repeating characters that are made to appear as one flying letter each. You can make the entire message a link by putting the anchor outside of the flying span:
    HTML Code:
    <h2><a href="some.htm"><span id="fly"></span></a></h2>
    or even:
    HTML Code:
    <h2><a href="some.htm" id="fly"></a></h2>
    It would be nice too, to add a noscript tag containing a default message and link for non javascript enabled browsers:
    HTML Code:
    <noscript><h2><a href="some.htm">Thanks for visiting Dynamic Drive!</a></h2></noscript>
    Be sure to add your link to the non-IE section as well and while we are at it, let's add in language to make it work in opera too (additions red):
    Code:
    if (!document.all||window.opera)
    document.write('<h2><a href="some.htm">'+message+'</a></h2>')
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you jscheuer1 worked a charm.

    Thankyou.
    Neticus

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
  •