【问题标题】:Colorbox not redirecting to my chosen URLColorbox 未重定向到我选择的 URL
【发布时间】:2011-10-11 19:51:13
【问题描述】:
<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>

脚本会根据需要关闭颜色框,但不会重定向到感谢页面。我在控制台中查找发生了什么,这是错误:

未捕获的类型错误:无法读取未定义的属性“位置”

任何帮助将不胜感激。

非常感谢。

【问题讨论】:

  • 这项工作是否可行:parent.$.fn.colorbox.close(); window.location.href = "search_message_thankyou.php";

标签: jquery colorbox


【解决方案1】:

如果您的颜色框正在 iframe 中加载内容,那么您可能需要尝试

window.parent.location.href = "search_message_thankyou.php";

【讨论】:

    【解决方案2】:

    尝试在关闭之前输入bind,如下所示:

    parent.$(document).bind('cbox_closed', function(){ 
    window.location.href = "search_message_thankyou.php";
        }); 
    });
    parent.$.fn.colorbox.close(); 
    

    您也可以使用parent.location.href = x

    【讨论】:

      【解决方案3】:

      他们的关键是从父页面启动绑定,而不是从 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-01
        • 1970-01-01
        • 2018-01-22
        相关资源
        最近更新 更多