如何预载iframe [英] How to preload iframe

查看:117
本文介绍了如何预载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);
});

前一段时间,我试图为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

$('#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天全站免登陆