Colorbox is a jQuery plugin,Nowadays jquery colorbox plugin is mostly used for displaying content in popup window. But there are still somethings where we stuck. Closing colorbox is one of them.
Colorbox plugin has Close public method for closing the colorbox window. But it depends on your design to show or not the close button. In latest colorbox plugin, you can set “closeButton” property to true/false.
For closing the colorbox window manually, options are as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $(function(){ $.colorbox.close(); //OR jQuery.colorbox.close(); //OR jQuery.fn.colorbox.close(); //OR $('#cboxClose').click(); // cboxClose is the default id of the colorbox close button }) |
2. On click of a link or button in colorbox content
1 2 3 4 5 6 7 8 | $(function(){ $('#linkId').click(function(){ $.colorbox.close(); }) }) |
3. On click of link or button in colorbox iframe content
1 2 3 4 5 6 7 8 | $(function(){ $('#linkId,#buttonId').click(function(){ parent.$.colorbox.close(); // or parent.$.fn.colorbox.close(); }) }) |
After all above given condition, there are another situations also, where we need to opt other way to close the colorbox window.But generally we faced the problem when colorbox in iframe.
But it is not so tricky to close the colorbox window. If you need any type of help in jQuery colorbox plugin or fancybox then write to us. We will try to provide you a solution as soon as possible.
Hi, I have an error when closing color box. Below is my code.
function OpenForm(url)
{
$.colorbox({
iframe: true,
href: url,
innerWidth: “530”,
innerHeight: “400”,
fixed: false,
overlayClose: false
});
return false;
}
Confirm
function CloseForm()
{
parent.$.fn.colorbox.close();
}
Cancel
I always get the error:
Uncaught SecurityError: Blocked a frame with origin “null” from accessing a frame with origin “null”. Protocols, domains, and ports must match.
Please help me solve this problem. Thanks a lot
Hi Herman
Sorry for being late. Your code is looking right and it seems cross origin iframe issue. Would you like to send link to your site for further checking?