Close ColorBox iFrame after submit

2020-02-08 04:13发布

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.

9条回答
smile是对你的礼貌
2楼-- · 2020-02-08 04:36

After the form is submitted in Frame 1, you can use the following JavaScript to reload the parent frame:

window.parent.location.reload(true);
查看更多
家丑人穷心不美
3楼-- · 2020-02-08 04:39

Just simply simulate a click on the close button, like this:

$("#cboxClose").click();
查看更多
做个烂人
4楼-- · 2020-02-08 04:39

Give form tag like this:

<form target="_top">

then after submit:

response.redirect("your form")
查看更多
贼婆χ
5楼-- · 2020-02-08 04:41

I would take a look at http://colorpowered.com/colorbox/core/example1/index.html

Specifically, look at "Example with Alerts"

查看更多
叼着烟拽天下
6楼-- · 2020-02-08 04:42
<form target="_top">
查看更多
该账号已被封号
7楼-- · 2020-02-08 04:53

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();
  }
});
查看更多
登录 后发表回答