2012-05-04 211 views
2

我使用colorbox模式弹出和弹出窗口的内容来自一个URL,因为这是显示在一个iframe中我怎样才能添加一个关闭按钮模式弹出?colorbox关闭按钮与iframe

感谢

这是彩盒

<a class="Modal" href="http://google.com" onclick="openModal();">Click here</a> 

代码和JS:

var openModal = function(){   
    $(".Modal").colorbox({ 
     iframe:true, 
     opacity:0.5, 
     scrolling:true, 
     width:832, 
     height:456, 
     top:60 
    }); 
} 
+0

的可能重复[?如何iframe中关闭颜色框(http://stackoverflow.com/questions/2101011/how在iframe中的关闭颜色盒) –

+0

我真的不知道如何显示和锚点链接,因为iframe是由colorbox生成的。 – Jay

+0

显示一些代码请 –

回答

8

尝试增加这colorbox-iframe.html

<input type="button" name="btnClose" value="Close" onclick="parent.$.colorbox.close()" /> 
+0

,但没有colobox-iframe.html我将用户重定向到一个URL – Jay

+1

我刚刚给出了一个例子colorbox-iframe.html。在您的情况下,您的Iframe链接和每个Iframe都有一个您可以使用的按钮它作为closebtn。 – coder

0

我从来使用colorbo X之前,但也许你想要通过jQuery在函数中添加关闭按钮:

var openModal = function(){   
    $(".Modal").colorbox({ 
     iframe:true, 
     opacity:0.5, 
     scrolling:true, 
     width:832, 
     height:456, 
     top:60 
    }); 

    $("<div class='thisClosesTheModal'>Close Modal</div>").appendTo(".Modal"); 
    // style .thisClosesTheModal to look like a close box 
} 

// and then the function that closes the modal 

$(".thisClosesTheModal").live('click', function(){ 

    $('Modal').hide(); 

}