最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open colorbox from inside a iframe on top of parent window - Stack Overflow

programmeradmin1浏览0评论

I have a page with an iframe. The link inside an iframe should open colorbox. It works fine.

But it opens the colorbox inside the iframe. Is it possible to open the iframe over the parent window.

I appreciate any help.

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

I have a page with an iframe. The link inside an iframe should open colorbox. It works fine.

But it opens the colorbox inside the iframe. Is it possible to open the iframe over the parent window.

I appreciate any help.

     $(function() {
          $('#ajax').colorbox({iframe: true });
     });
Share Improve this question asked Feb 8, 2012 at 13:23 Josh RandallJosh Randall 1,3544 gold badges18 silver badges31 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

You should be able to trigger it in the top frame with

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

Although you'll need to spoon-feed it the data you want showing.

Had the same problem. solved by putting a function in the parent page like the one below:

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

then call the colorbox function in your iframe using:

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

above code is not working for me..

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

This code working...

发布评论

评论列表(0)

  1. 暂无评论