0

Basically, I want the iframe to fade out, then load a new url, then fade back in. Right now my code just fades out and (presumably, I can't really see it) loads the new page. I'm using $('iframe').ready(function(){ /*code that changes the src of the iframe*/ });

4

2 回答 2

1

像这样的东西?

示例:http: //jsfiddle.net/EcRBv/1/

function changeIframe(newSrc){
    $("#iframe1").fadeOut('fast',function(){
        $(this).attr("src",newSrc);
        $(this).load(function(){
            $(this).fadeIn("fast"); 
        });
    });
}

changeIframe("http://www.jsfiddle.net");
于 2013-05-26T20:29:39.030 回答
-1

像这样使用.load()或更改 iframe .attr('src')

$(document).ready(function(){
  $('iframe').animate({opacity:0}, 300, function(){
    //load or change source inside this callback     
  })
  $('iframe').animate({opacity:1}, 300};
})
于 2013-05-26T20:27:48.807 回答