Close ColorBox iFrame after submit

diEcho picture diEcho · Jan 6, 2010 · Viewed 45.9k times · Source

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:

  1. iFrame closes automatically.
  2. Parent window getting refresh automatically.

Please help me out.

Answer

nik picture nik · Mar 29, 2010

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();