Advanced Search

Results 1 to 10 of 10

Thread: Fading?

  1. #1
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fading?

    Okay. So, I'm an amateur website creator. I like to throw stuff together in my spare time and think that they're wonderful! Well, I'm currently making a website for a friend. I kind of owe this person.. so I promised to do anything they wanted me to, within my limit. And therein is my diliemma! See, my friend wants this special feature thing, where the pages in a frame "fade in" instead of just "blinking" up. I'm not sure how else to describe it... I refuse to post the site, due to some laughter I might receive, but if anyone could possibly explain to me if this can be done or not, I'd appreciate it! Ohhh, and if it could be done, point me in the right direction of where I can find the code? xD

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Meh. Simple fix:
    Code:
    window.onload = fade
    var i = 0
    function fade() {
    if (i < 100) {
    	i=i+10
    	}
    var d = document.body.style
    d.filter = "alpha(Opacity="+i+")"
    d.opacity = i/100
    var num = document.all ? 10 : 100
    setTimeout("fade()",num)
    }
    - Mike

  3. #3
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Woah, thanks!

    Now.. where do I put it? o.o

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You know how your html layout is done?
    Code:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>
    It goes in the <head> of your document (highlighted in red).

    Oh, you also have to surround the code I gave you with this tag:
    Code:
    <script type="text/javascript">...</script>
    Resulting:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    window.onload = fade
    var i = 0
    function fade() {
    if (i < 100) {
    	i=i+10
    	}
    var d = document.body.style
    d.filter = "alpha(Opacity="+i+")"
    d.opacity = i/100
    var num = document.all ? 10 : 100
    setTimeout("fade()",num)
    }
    <script>
    </head>
    <body>
    </body>
    </html>
    - Mike

  5. #5
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh!

    So this will work with the pages displayed in the frame?
    I only ask because it seems so simple.. and I was expecting something with the "iframe" or whatever tag in it.

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Apply that code to the page in the frame.
    - Mike

  7. #7
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You rock. <3

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Thanks
    - Mike

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

    Default

    Urgh... browser detection

    You could use my FadableObject script:
    Code:
    <script type="text/javascript" src="http://www.twey.co.uk/includes/FadableObject.js"></script>
    <script type="text/javascript">
      window.onload = function() {
        (new FadableObject(document.body, 1, 10, 0, 100, true, true)).fadeIn();
      };
    </script>
    setTimeout("fade()",num)
    }
    <script>
    That should be </script>. Also, setTimeout(fade, num) would be preferable: using strings with setTimeout() is usually unnecessary, and tends to require global variables, making it worse than eval().
    Last edited by Twey; 01-13-2007 at 02:04 PM.
    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!

  10. #10
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    It's always about YOU isn't it, Twey. Just joking lol.. you are more right, I just thought of that script when this was posted, I didn't even test it
    - Mike

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
  •