【问题标题】:How to open colorbox from inside a iframe on top of parent window如何从父窗口顶部的 iframe 内部打开颜色框
【发布时间】:2012-02-08 13:23:35
【问题描述】:

我有一个带有 iframe 的页面。 iframe 内的链接应打开颜色框。它工作正常。

但它会打开 iframe 内的颜色框。是否可以在父窗口上打开 iframe。

感谢您的帮助。

     $(function() {
          $('#ajax').colorbox({iframe: true });
     });

【问题讨论】:

    标签: javascript jquery modal-dialog colorbox


    【解决方案1】:

    您应该能够在顶部框架中触发它

    top.$.fn.colorbox({ params });
    

    虽然你需要用勺子喂它你想要显示的数据。

    【讨论】:

    • 觉得应该是 top.$.colorbox({ params });上面的代码在我的情况下不起作用。
    【解决方案2】:

    遇到了同样的问题。通过在父页面中放置一个函数来解决,如下所示:

    <script>    
    $(document).ready(function(){
    function call_colorBox(params) {
            $.colorbox(params);
        }
    })
    </script>
    

    然后在你的 iframe 中调用 colorbox 函数:

    <script>
    top.parent.call_colorBox({ width: "80%", height: "80%", iframe: true, href:"http://www.google.com" });
    </script>
    

    【讨论】:

      【解决方案3】:

      上面的代码对我不起作用..

      top.parent.$.colorbox({ 
          iframe: true, 
          width: "75%", 
          height: "75%",
          href: "frmTATABomPartsUnique.aspx?Parts=Common",
          title: "UNIQUE PARTS", 
          onComplete: function () {
              $("#cboxClose").attr("title", "Close"); 
          } 
      });
      

      此代码工作...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-25
        相关资源
        最近更新 更多