我的问题是,我需要一个colorbox来重新加载父页关闭。Colorbox重新加载父页关闭
这是我有:
$(".example").colorbox({
onClosed:function(){
parent.location.reload();
}
});
彩盒加载罚款,但不会刷新关闭父页面。有任何想法吗?
我的问题是,我需要一个colorbox来重新加载父页关闭。Colorbox重新加载父页关闭
这是我有:
$(".example").colorbox({
onClosed:function(){
parent.location.reload();
}
});
彩盒加载罚款,但不会刷新关闭父页面。有任何想法吗?
使用window.location.reload();
或window.location = window.location;
代替parent.location.reload();
谢谢+1!这对我有用;) – 2011-07-22 19:51:09
或者只是使用
<input type="submit" onclick="parent.location.reload()" value="Save" name="submit"/>
我喜欢这一个了卢卡斯的解决方案,因为你也可以轻松地创建
<input type="button" onclick="javascript:parent.$.colorbox.close()" value="Cancel" />
没有它重装整个页面。
function __colorbox_onClose(e) {
$.fn.colorbox.close();
return false;
}
$.fn.colorbox.close(); - Closes colorbox manually
return false; - reloads/Autopostbac's form from which you called colorbox
有点延迟,但我有另一个答案。您可以将代码发送到在colorbox中加载的目标页面上的重新加载窗口。
我正在使用colorbox登录/ how_it_works/faqs &其他几个功能。我只希望我的父页面在“登录”的情况下重新加载。因此,在回复登录表单时,我发送了以下代码:
<script type="text/javascript">
window.parent.location.reload();
</script>
'窗口'是colorbox窗口。我要求其父(浏览器窗口)重新加载。
这里是我的通用颜色框开启功能:
它可以:
另外:
主要的一点是,你应该有(当然,如果你知道自己在做什么)一些全球性的JavaScript变量,就是这样。
function showActionForColorBox(
_url,
_forFocus
) {
_url = fixURLWithMasterServerPrefix(_url);
$.colorbox(
{
scrolling: false,
href: _url,
onLoad: function() {
idColorboxAjaxIndect1.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect2.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect3.appendTo($('#cboxOverlay'));
idColorboxAjaxIndect4.appendTo($('#cboxOverlay'));
return;
},
onComplete: function() {
if (_forFocus) {
var c = $('#' + _forFocus);
if (c.length) {
c.focus();
}
}
return;
},
onCleanup: function() {
// TODO: ?
return;
},
onClosed: function() {
abortAllAsyncAjaxRequests();
if (shouldReloadPageAfterColorBoxAction) {
shouldReloadPageAfterColorBoxAction = false; // NOTE: To be sure: Reset.
reloadWholePage();
}
else if (cbEBillsActionReloadPopup) {
cbEBillsActionReloadPopup = false;
// NOTE: WE HAVE AN OPTION TO RELOAD COLORBOX WITH CUSTOM URL !
showActionForColorBox((cbActionReloadPopupCustomURL !== '' ? cbActionReloadPopupCustomURL : _url));
cbActionReloadPopupCustomURL = '';
}
else if (cbShouldLoadAnotherContentAfterClosed) {
cbShouldLoadAnotherContentAfterClosed = false;
$.colorbox({ html: setupContentForcbShouldLoadAnotherContentAfterClosed });
setupContentForcbShouldLoadAnotherContentAfterClosed = '';
}
return;
}
}
);
return;
}
$(document).bind('cbox_closed', function(){
location.reload();
});
上面的代码是用于颜色框默认关闭(X)按钮。
如果你有那么你自己的关闭按钮尝试这样的:
$('#id').click(function(){
location.reload();
});
不要忘了接受的答案。 – 2012-08-16 17:52:45