Results 1 to 3 of 3

Thread: Changing Font

  1. #1
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing Font

    I am using the following script. How do I change the size/type/color of the font? Also the Speed?

    Thanks for any help !!!





    <html>

    <body>

    <h2><span id="fly"></span></h2>

    <script>
    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 = " THIS IS WHERE THE MESSAGE GOES " // $ = taking a new line
    distance = 150 // pixel(s)
    speed = 30 // milliseconds

    if (!document.all)
    document.write('<h2>'+message+'</h2>')

    </script>

    <script language="JavaScript1.2">

    txt="";num=0;num4=0;flyofle="";flyofwi="";flyofto=""
    function stfly(){for(i=0;i != message.length;i++){if(message.charAt(i) != "$"){txt=txt+"<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"<\/span>"};else{txt=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=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.f loor(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+","+num 3+")",50)}};

    stfly()

    </script>

    </body>
    </html>
    Last edited by rowland; 06-02-2005 at 01:53 PM.

  2. #2
    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

    The best way is to include a style section in the head of the document:
    Code:
    <html>
    <head><title>Flying Letters - Demo</title>
    <style type="text/css">
    #fly span {
    font-family:Arial;
    font-size:.5em;
    color:red;
    background:#d0d0d0;
    }
    </style>
    </head>
    <body>
    . . . or add to an existing style section. As your example has no style, head or title, I've created them for it. Just replace everything up to and including the <body> tag in your example with the above.
    - John
    ________________________

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

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

    Default

    Thanks...that works...

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
  •