延迟加载iframe? [英] Delay load of iframe?

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

问题描述

我知道有一些工具和技术可以延迟javascript的负载,但我有一个iframe,我想延迟加载,直到页面的其余部分完成下载和渲染(iframe隐藏在直到有人点击页面上的特定标签才会显示。有没有办法延迟iframe的加载?任何建议都会非常感谢。谢谢!

I know there are some tools and techniques for delaying the load of javascript, but I have an iframe that I would like to delay loading until after the rest of the page has finished downloading and rendering (the iframe is in a hidden that will not be revealed until someone clicks on a particular tab on the page. Is there a way to delay the load of an iframe? Any suggestions would be much appreciated. Thanks!

推荐答案

使用jquery很容易!

with jquery it is easy!

将您的代码加载到 $中加载iframe( )
或使用 $(文件).ready(function(){})
这两者都是相同的在DOM准备好后会执行你的代码!

either enclose your code which loads the iframe within a $() or use $(document).ready(function(){}) these both are the same and would execute your code after the DOM is ready!

例如

$(document).ready(function(){
    $('iframe#iframe_id').attr('src', 'iframe_url');    
});

更多信息见 http://www.learningjquery.com/2006/09/introducing-document-ready

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

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