预加载iframe [英] Preload iframe

查看:190
本文介绍了预加载iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

        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);
        });

Hello stackoverflow,

Hello stackoverflow,

前一段时间我试图动画div,好吧,它现在只有一件事。
激活第一个函数(从第3行开始),iframe被加载。但是现在,我怎么能预加载那个iframe?因为当动画结束时iframe没有加载...

A while ago i was trying to animate a div, well, it works now only one thing. When the first function is activated (starting row 3), and iframe gets loaded. But now, how can i preload that iframe? Because when the animation is finished the iframe isn't loaded...

问候

推荐答案

使用JQuery,您不需要使用iframe。看一下.load()函数。 http://api.jquery.com/load

With JQuery, you don't need to use iframes. Take a look at the .load() function. http://api.jquery.com/load

ie

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

要预加载页面,只需创建一个隐藏的div并在准备就绪时显示。

To preload a page, just create a hidden div and show it when ready.

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

这篇关于预加载iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆