本文介绍了colorbox bug-通过链接或按钮关闭colorbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过调用打开弹出窗口

I open the popup by calling

$.colorbox({ href: "notification.aspx" });

在notification.aspx中,我有

In notification.aspx I have

<script type="text/javascript" src="/scripts/colorbox/jquery.colorbox-min.js"></script>
...
<a id="btnClose">OK</a>

显示弹出窗口很好,但是当我单击按钮时,它显示了JavaScript错误.

The popup was shown fine, but when I click the button it gives a JavaScript error.

我在主页的javascript中

In the main page's javascript I have

$('#btnClose').live('click', function () {
  alert('closing...'); // Alert shown as expected
  $.colorbox.close(); // Nothing happens, no JavaScript error
  //$.fn.colorbox.close(); // same
  //parent.$.fn.colorbox.close(); // same
  //$.colorbox.remove(); // same
  //$('#cboxClose').click(); // same
  //$('#cboxOverlay').click(); // same
});

我只是想关闭弹出窗口.

I am just trying to close the popup.

我想念什么?预先感谢.

What am I missing? Thanks in advance.

我以某种方式使它工作,我将找出使它起作用的原因.

I got it working somehow, I'll find out what made it works.

推荐答案

$.colorbox.close()是关闭颜色框的正确方法,请不要听其他注释.问题在于您是第二次加载colorbox.从notification.aspx中删除jquery.colorbox.js脚本块.

$.colorbox.close() is the correct way to close colorbox, do not listen to these other comments. The problem is that you are loading colorbox a second time. Remove the jquery.colorbox.js script block from notification.aspx.

这篇关于colorbox bug-通过链接或按钮关闭colorbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 01:46