我想防止意外关闭颜色框,因此我将从加载的 iframe 内部显示/隐藏关闭按钮。
我阅读了文档,但两个示例似乎都不起作用:
var originalClose = $.colorbox.close;
$.colorbox.close = function(){
var response;
if($('#cboxLoadedContent').find('form').length > 0){
response = confirm('Do you want to close this window?');
if(!response){
return; // Do nothing.
}
}
originalClose();
};
或者
<!-- calling colorbox's close method from within an iframe: -->
<a href='#' onclick='parent.$.colorbox.close(); return false;'>close this iframe</a>
...彩盒只是没有关闭。我究竟做错了什么?
在控制台中我看到:
Uncaught TypeError: Cannot read property 'colorbox' of undefined
谢谢!