2011-02-03 10 views
4
 function toggle(){ 
      $("#tempc").toggle(
       function() { 
        $("#tempc").animate({width: 255, height: 220}, 1000); 
        $("#tempc").html(""); 
        $("#tempc").css("background-color", "transparent"); 
        $("#tempc").html("<iframe src='/src/stream.php?stream=1' width='255' height='225' frameborder='0' scrolling='no'></iframe><br><a href='javascript:;' onclick='hidegadget();' class='yellowblock'>Sluit</a>"); 
       }, 
       function() { 
        $("#tempc").animate({width: 50, height:50}, 1000); 
        $("#tempc").html(""); 
        $("#tempc").css("background-color", "#FFFF00"); 

        $.get('src/stream.php?stream=2', function(data002) { 
         $('#tempc').html(data002); 
        }); 
       } 
      ); 
     } 

     $.get('src/stream.php?stream=2', function(data002) { 
      $('#tempc').html(data002); 
     }); 

こんにちはstackoverflowの、プリロードはiframe

しばらく前に私はdiv要素をアニメーション化しようとしていた、まあ、それは今だけ一つのことを動作します。 最初の機能がアクティブになっているとき(行3を開始)、iframeが読み込まれます。しかし、今、どうすればそのiframeをプリロードできますか?アニメーションが終了したときのiframeがロードされていないので...

挨拶

答えて

5

JQueryでは、iframeを使用する必要はありません。 .load()関数を見てみましょう。 http://api.jquery.com/load

すなわち

$('#tempc').load('src/stream.php?stream=1'); 

だけ隠しdiv要素を作成し、準備ができたら、それを表示し、ページをプリロードします。

var stream2 = $('<div>').load('src/stream.php?stream=2').hide(); 
$('#tempc').html(stream2.html()); 
1

スタートはインラインフレームをロードすることによって、これ自体であなたに頭痛を与えるかもしれない(インラインフレームにonLoadにフックが、少しグーグルでは、この作業をブラウザ間でうまくやり遂げる方法を示す必要があります)、このイベントからアニメーションを実行します。

関連する問題