<script>
$(document).ready(function() {
$('#reset_password').live('click', function(e) {
parent.$.fn.colorbox.close();
parent.$(document).bind('cbox_closed', function(){
window.location.href = "search_message_thankyou.php";
});
});
});
</script>
脚本会根据需要关闭颜色框,但不会重定向到感谢页面。我查看控制台中发生了什么,这是错误:
未捕获的TypeError:无法读取未定义的属性“位置”
非常感谢任何帮助。
非常感谢提前。
答案 0 :(得分:1)
如果您的颜色框正在iframe中加载内容,那么您可能需要尝试
window.parent.location.href = "search_message_thankyou.php";
答案 1 :(得分:0)
在关闭之前尝试放置bind
,如下所示:
parent.$(document).bind('cbox_closed', function(){
window.location.href = "search_message_thankyou.php";
});
});
parent.$.fn.colorbox.close();
或者你可以做parent.location.href = x
。
答案 2 :(得分:0)
它们的关键是从父页面启动绑定,而不是从iframe启动绑定。
在我自己的解决方案中,我使用了以下示例:
$(document).ready(function(){
$(".iframe").colorbox({width:"80%", height:"80%", iframe:true});
if ($('.btn_OpenColorbox').length) {
//check for existence of colorbox open button
//bind and redirect after colorbox closes
$(document).bind('cbox_closed', function () {
window.location.assign('My-Redirect-Page.aspx');
});
}
$('.btn_CloseColorbox').click(function () {
//close colorbox
parent.$.colorbox.close();
});
}
这里有另一个例子:https://groups.google.com/forum/?fromgroups#!topic/colorbox/jSrZSoW7P3s