SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text fade in without body onLoad

    Hi,

    Is there any way of fading in some text without using <body onLoad()>?

    I need something that works like this
    Code:
    <html>
    <head>
    <script language="javascript">
    var r = 255;
    var g = 255;
    var b = 255;
    function fade(id) { 
    document.getElementById(id).style.visibility = "visible";
    document.getElementById(id).style.color="rgb(" + r + "," + g + "," + b + ")";
    r -= 5
    g -= 5
    b -= 5
    if(r>0) 
    setTimeout("fade('"+id+"')", 40); 
    }
    function startfade(id) {
    window.setTimeout("fade('fade');", 100);
    }
    </script>
    </head>
    <body onLoad="startfade('fade');">
    <p>
    <span id="fade" style="visibility: hidden;">This text needs to fade in 8 seconds after page load!</span><br>
    test
    </p>
    </body></html>
    But that doesnt require the body part.

    Any ideas?!

    Thanks

    Sorry, is there any way of moving this to the Javascript forum?!
    Last edited by grandad; Mar 21, 2007 at 15:18. Reason: Wrong forum!

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just place
    HTML Code:
    <script type="text/javascript">fade('fade')</script>
    anywhere on the page below the text to be faded.
    Saul


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
  •