Jquery和Ajax动态加载IFrame [英] Jquery and Ajax to Dynamically load IFrame

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

问题描述

我有一个动态加载网页内iframe的脚本。您可以在此处查看演示: DEMO

I have a script that dynamically loads iframes inside a webpage. You can see the demo here: DEMO

我想用jquery来实现类似的rseult,但是有一个很好的滑动效果,以及在另一个div中加载iframe的外部链接。基本上,我在页面上有10个链接。单击链接时,我希望iframe窗口加载新内容并将效果应用于过渡。有没有人知道为此存在的任何插件?我没有足够的经验从头开始编写脚本,所以任何帮助都会非常感激!

I want to use jquery to achieve a similar rseult, but with a nice sliding effect, and external links that load the iframe in another div. Basically, I have 10 links on a page. When the link is clicked, I want the iframe window to load in the new content and apply an effect to the transition. Does anyone know of any plugins that exist for this? I am not experienced enough to write a script from scratch, so any help would be much appreciated!

推荐答案

根据评论进行了更改。 ..

Changed based on comments...

给定页面

<input type="button" value="Load Frames" id="submit" name="submit" onclick="loadFrame()" />
<iframe class="frameToChange" link="http://www.apple.com" style="display: none" ></iframe>
<iframe class="frameToChange" link="http://www.google.com" style="display: none" ></iframe>

尝试以下内容

function loadFrame() {
    var j$ = jQuery.noConflict();
    var frames = j$('.frameToChange');

    frames.each(function(index) {
        j$(this).slideDown('fast');
        j$(this).attr('src', j$(this).attr('link'));
    });
}

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

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