2013-08-19 63 views
-1

我必须HTML窗体可见,其中一个隐藏并提交到背景。我使用jQuery脚本来提交隐藏的表单。在后台提交表单后,我想将我的页面重定向到http://www.youtube.com/。你可以添加代码到我的代码如何重定向?如何在提交表单后重定向页面

jQuery脚本

<script type="text/javascript"> 
$(function(){ 
    $("#blast").click(function(){ 
     if($("#email").val() == ""){ 
     alert("Please enter email value"); 
     } else { 
     // submit the form 
      $('#email1,#email2').val($('#email').val()); 
      $('#form2,#form3').submit(); 
      alert('Thanks'); 
      return false; 
     } 
    }); 
    $('#email').keypress(function(e){ 
     if(e.which == 13){//Enter key pressed 
      $('#blast').click();//Trigger search button click event 
     } 
    }); 
}); 

+2

[Answer is here](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript) – u54r

回答

0

你真的会用Google如何将这种在两秒钟,但是这是你如何重定向到另一页。

window.location = 'http://www.youtube.com/'; 

,或者您可以使用:

window.location.replace("http://www.youtube.com/"); 

window.location.href = "http://www.youtube.com/"; 
1

如果您需要在提交表格后,将用户重定向,它没有任何意义的JavaScript做。用javascript提交表单的重点在于,您不必重新加载页面。只需将用户发送到处理表单数据的页面,并让该页面发送Location: youtube.com/whaaaaarg标题。