【问题标题】:How to close colorbox with a button如何使用按钮关闭颜色框
【发布时间】:2013-03-02 17:28:30
【问题描述】:

我使用彩盒 iframe:

$(document).ready(function(){
    $(".iframe").colorbox({iframe:true, width:"85%", height:"65%", fastIframe:false});      
});

在我的第二页上,我有一个按钮,我想在其中发布一些图像,并且在操作之后我想关闭框架窗口。

<input type="button" id="selected" value="the_button" />

和脚本

$( document ).ready(function() {

    $("#selected").bind('click',function() {

        window.setTimeout(function() 
        {
            $.colorbox.close(); 
        }, 2500);

        alert('hi');

    });

});

【问题讨论】:

    标签: jquery button iframe colorbox


    【解决方案1】:

    试试这样:

    $( document ).ready(function() {
    
        $("#selected").bind('click',function() {
    
            window.setTimeout(function() 
            {
               parent.$.colorbox.close();
            }, 2500);
    
    
        });
    
    });
    

    【讨论】:

    • 谢谢,@Ares,但我试试这个并没有帮助。我也尝试 $("#selected").click( function() { parent.jQuery.colorbox.close(); return false; });它显示错误“访问属性'jquery'的权限被拒绝”
    • 如果我评论“parent.jQuery.colorbox.close(); return false;”并输入“alert('hi');”显示正确,没有错误。
    • 什么是html标签#selected?
    【解决方案2】:

    我遇到了同样的问题,我使用了$('#cboxClose').remove();,它对我有用。

    【讨论】:

      【解决方案3】:

      将此添加到您的 HTML 中:

      <a href="#" onClick="$.colorbox.close();">Close Colorbox</a>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-05
        • 2019-12-03
        • 1970-01-01
        • 1970-01-01
        • 2023-01-15
        • 1970-01-01
        • 2013-04-20
        • 1970-01-01
        相关资源
        最近更新 更多