jquerymobile和php用于电子邮件,php赢得';不要重定向到第页

jquerymobile和php用于电子邮件,php赢得';不要重定向到第页,php,jquery,redirect,mobile,Php,Jquery,Redirect,Mobile,我有一个带有jquery mobile的html页面 我有一个按钮,调用php脚本发送电子邮件 HTML 您的姓名: 您的电子邮件: 您的留言: Php正在发送电子邮件,然后应该使用window.location.href=''重定向到主页 PHP: 提醒('谢谢您的留言。我会很快与您联系。'); window.location.href=http://www.example.com/Portfolio.html'; 警报('消息失败'); window.location.href=

我有一个带有jquery mobile的html页面

我有一个按钮,调用php脚本发送电子邮件

HTML


您的姓名:

您的电子邮件:

您的留言:

Php正在发送电子邮件,然后应该使用window.location.href=''重定向到主页

PHP:


提醒('谢谢您的留言。我会很快与您联系。');
window.location.href=http://www.example.com/Portfolio.html';
警报('消息失败');
window.location.href=http://www.example.com/Portfolio.html';
?>
它不起作用!!电子邮件已发送,但不会重定向

我知道这与jquerymobile如何加载页面有关,但我不知道如何解决这个问题


有什么帮助吗?

我建议使用
window.location.replace()
此方法将在当前浏览器窗口中用新页面替换当前页面
replace()
从历史记录中删除当前页面,因此它不会返回到原始页面

window.location.replace("http://www.example.com/Portfolio.html");
有关该方法的更多信息:


粘贴jquery代码。
<?php
 $action=$_REQUEST['action'];

     $name=$_POST['name'];
     $email=$_POST['email'];
$message=$_POST['message'];
$mail_to='i.nassiopoulos@gmail.com';

if (($name=="")||($email=="")||($message==""))
    {
    echo "All fields are required, please fill <a href=\"\">the form</a>     again.";
    }
else{
    $subject = ' New message ' . $field_name;
    $body_message = 'From: '.$name."\n";
    $body_message .= 'E-mail: '.$email."\n";
    $body_message .= 'Message: '.$message;
    $headers = "From: $cf_email\r\n";
    $headers .= "Reply-To: $cf_email\r\n";

    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    mail($email,$subject,$body_message,$headers); 
    }

 if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
    alert('Thank you for the message. I will contact you shortly.');
    window.location.href = 'http://www.example.com/Portfolio.html';
</script>
 <?php
 }
 else { ?>
<script language="javascript" type="text/javascript">
    alert('Message failed.');
    window.location.href = 'http://www.example.com/Portfolio.html';
</script>
 <?php
 }?>

 ?>
window.location.replace("http://www.example.com/Portfolio.html");