views:

799

answers:

2

Hi everyone,

Is it possible to make fade in and fade out transitions in iframes?

Thanks & Regards

Ravi

+2  A: 

you can do it with jquery!

http://docs.jquery.com/Effects/fadeOut

http://docs.jquery.com/Effects/fadeIn

Konstantinos
+2  A: 

Fading in or out can be achieved by changing the opacity of an element over time, a very simple example:

var iframe = document.getElementById('iframe');

fadeOut(iframe, 1000);

function fadeOut(el, duration) {

    /*
     * @param el - The element to be faded out.
     * @param duration - Animation duration in milliseconds.
     */

    var step = 1 / duration * 10,
        opacity = 1;
    (function(){
        if (opacity <= 0) { return; }
        el.style.opacity = ( opacity -= step );
        setTimeout(arguments.callee, 10);
    })();

}


While jQuery is an incredible library your usage of it should be justified by more than just its ability to create fancy effects. A library should be adopted for its completeness and ease of use; not because it happens to offer just one thing you might want to use.

J-P