将URL添加到一个iFrame基于IFrame的ID被称为Fancybox2阿贾克斯 [英] Adding a URL to an Iframe being called by Fancybox2-AJAX Based on the Iframe's ID

查看:122
本文介绍了将URL添加到一个iFrame基于IFrame的ID被称为Fancybox2阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有这方面的工作减去有这个工作,一旦我呼吁在的fancybox通过AJAX的事实。

Okay I have this working minus the fact of having this working once I call in with fancybox via AJAX.

静态示例如下:

 <iframe id="videourl1" width="640" height="340" src="" frameBorder="0"></iframe>
 <iframe id="videourl2" width="640" height="340" src="" frameBorder="0"></iframe>
 <iframe id="videourl3" width="640" height="340" src="" frameBorder="0"></iframe>

$("div.video-container iframe").each(function(){var idAdd=$(this).attr("id");$(this).attr("src","http://www.youtube.com/embed/"+idAdd+"?rel=0&autoplay=0&modestbranding=1&showinfo=0&autohide=1")})

现在,当我借此拉的3内置页框成txt文件,并使用fancybox2-AJAX调用它从一个index.html文件称他们为失败:

Now when I take this and pull the 3 iframes into .txt files and call them from an index.html file using fancybox2-ajax call it fails:

的index.html:

Index.html:

  <a id="1" class="fancybox fancybox.ajax" href="text/1.txt">Link</a>
  <a id="2" class="fancybox fancybox.ajax" href="text/2.txt">Link</a>
  <a id="3" class="fancybox fancybox.ajax" href="text/3.txt">Link</a> 

文本文件包含了内置页框:

Text files contain the iframes:

  <iframe id="videourl" width="640" height="340" src="" frameBorder="0"></iframe>

我如何C中的JS $ C $说每次运行时的iframe是由AJAX调用的时间?

How do I code the JS to say run each time when the iframe is called in by AJAX?

推荐答案

答:

$(".fancybox").fancybox({
    afterShow: function () {
        $("div.video-container iframe").each(function () {
            var idAdd = $(this).attr("id");
            $(this).attr("src", "http://www.youtube.com/embed/" + idAd‌d + "?rel=0&autoplay=0&modestbranding=1&showinfo=0&autohide=1")
        });
    }
});

这篇关于将URL添加到一个iFrame基于IFrame的ID被称为Fancybox2阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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