Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在jquery fancybox弹出窗口中重定向到下一页…在jquery中_Javascript_Jquery_Ajax_Fancybox 2 - Fatal编程技术网

Javascript 如何在jquery fancybox弹出窗口中重定向到下一页…在jquery中

Javascript 如何在jquery fancybox弹出窗口中重定向到下一页…在jquery中,javascript,jquery,ajax,fancybox-2,Javascript,Jquery,Ajax,Fancybox 2,我正在使用jquery花式方框弹出窗口…用于弹出。。。。 但当我提交时…我的表单在同一窗口中重定向…在弹出窗口中。。 我想将我的页面重定向到另一个打开的窗口…不在同一个弹出窗口中 我使用了目标空白。但它每次都有效。每次单击时…我需要在登录完成后重定向。。。。 我正在codeigniter中创建我的项目 我的控制器 public function login() { if ( $this->input->post('action') ) {

我正在使用jquery花式方框弹出窗口…用于弹出。。。。 但当我提交时…我的表单在同一窗口中重定向…在弹出窗口中。。 我想将我的页面重定向到另一个打开的窗口…不在同一个弹出窗口中

我使用了目标空白。但它每次都有效。每次单击时…我需要在登录完成后重定向。。。。 我正在codeigniter中创建我的项目

我的控制器

public function login()
    { 
        if ( $this->input->post('action') )
        {       
            $this->form_validation->set_rules('user_name', 'Username','required|valid_email');
            $this->form_validation->set_rules('password', 'Password', 'required|');


            if ($this->form_validation->run() == TRUE)
            {

                $username  =  $this->input->post('user_name');
                $password  =  $this->input->post('password');               
                $rember    =  ($this->input->post('remember')!="") ? TRUE : FALSE;

                 if( $this->input->post('remember')=="Y" )
                 {
                        set_cookie('userName',$this->input->post('user_name'), time()+60*60*24*30 );
                        set_cookie('pwd',$this->input->post('password'), time()+60*60*24*30 );
                  }
                  else
                  {                      
                        delete_cookie('userName');
                        delete_cookie('pwd');
                  }     

                $this->auth->verify_user($username,$password);  

                if( $this->auth->is_user_logged_in() )
                {
                      if( $this->session->userdata('ref')!=""  )
                      { 

                        redirect($this->session->userdata('ref'),'');   

                      }
                      else
                      {

                         redirect('members/myaccount','refresh'); 

                      }


                }
                else
                {

                    $this->session->unset_userdata(array("ref"=>'0'));
                    $this->session->set_userdata(array('msg_type'=>'error'));
                    $this->session->set_flashdata('error',$this->config->item('login_invalid'));        
                    redirect('users/login', '');
                }

            }
            else
            {
                $data['heading_title'] = "Login";           
                $this->load->view('users_login',$data); 
            }               
        }
        else
        {
            $data['heading_title'] = "Login";           
            $this->load->view('users_login',$data);     
        }
    } 
$(窗口)。加载(函数(e){
$(“#后顶”).hide();
$(函数(){
$(窗口)。滚动(函数(){
如果($(this).scrollTop()>100){
$(“#后顶”).fadeIn();
}否则{
$(“#后顶”).fadeOut();
}
})
});
$(“.login”).fancybox({
“宽度”:367,
‘高度’:600,
“自动缩放”:false,
“type”:“iframe”
});
$(“.fotget”).fancybox({
“宽度”:425,
‘高度’:286,
“自动缩放”:false,
“type”:“iframe”
});
$(“.profile”).fancybox({
“宽度”:700,
“高度”:505,
“自动缩放”:false,
“type”:“iframe”
});
$(“.details”).fancybox({
“宽度”:400,
‘高度’:200,
“自动缩放”:false,
“type”:“iframe”
});
$(“.inquiry”).fancybox({
“宽度”:359,
‘高度’:450,
“自动缩放”:false,
“type”:“iframe”
});
$(“.contact”).fancybox({
“宽度”:317,
‘高度’:353,
“自动缩放”:false,
“type”:“iframe”
});
$(“.map”).fancybox({
“宽度”:425,
“高度”:355,
“自动缩放”:false,
“type”:“iframe”
});
});

发生这种情况的原因是因为您的弹出内容是iframed。。。您可以将消息发送回父窗口,以便在主浏览器窗口中执行重定向,与其父窗口的google on iframe通信将为您获取执行此操作所需的信息,但是这一切都取决于您是否能够控制正在iframe中的页面

示例:…无论您的重定向在何处…替换为

echo "<script type=\"text/javascript\">window.top.postMessage('logged_in', '*');</script>";
exit; //make sure this is here, to stop php execution!!
注意:“登录”也可以是json字符串

'{ "action":"something","redirect":"http://url" }'
只用

JSON.parse(e.data); 
在侦听器中提取json对象

编辑:废话。。。我误解了你的问题。。。我看不到您用于提交表单的元素。。。但通常你会做e.preventDefault();在让它重定向到任何地方之前,在该元素上…例如,您正在使用锚标记

$('a.form-submit').on('click',function(e){
  e.preventDefault();
  var redir = $(this).attr('href');
  var formData = $('#theform').serialize();
  $.post('http://formhandler/route',formdata,function(){
    //open a new window...
    window.open(redir);
    //or send data back to parent window...
    window.top.postMessage(redir,'*');
  });
});
$('a.form-submit').on('click',function(e){
  e.preventDefault();
  var redir = $(this).attr('href');
  var formData = $('#theform').serialize();
  $.post('http://formhandler/route',formdata,function(){
    //open a new window...
    window.open(redir);
    //or send data back to parent window...
    window.top.postMessage(redir,'*');
  });
});