I'm using jQuery ColorBox
to display a shopping cart item. When a user enters the quantity in the iFrame (opened with colorbox) and clicks on the submit button, I want the iFrame to be close and main window (parent) to be refreshed automatically.
I mean I want two things after submitting data on iFrame:
Please help me out.
use this on the parent window while opening iframe:
$(document).ready(function(){
$(".chpic").colorbox({width:"80%", height:"80%", iframe:true,
onClosed:function(){ location.reload(true); } });
});
and this to close the iframe inside iframe page:
parent.$.fn.colorbox.close();
After the form is submitted in Frame 1, you can use the following JavaScript to reload the parent frame:
window.parent.location.reload(true);
<form target="_top">
open jquery.colorbox.js find these two pieces of code:
$close.click(function () {
publicMethod.close();
});
$overlay.click(function () {
if (settings.overlayClose) {
publicMethod.close();
}
});
replace with these - note the addition of " window.location.reload();"
$close.click(function () {
publicMethod.close();
window.location.reload();
});
$overlay.click(function () {
if (settings.overlayClose) {
publicMethod.close();
window.location.reload();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With