Javascript,弹出警告后重新加载HP而不使用URL

3
我有一个在flash网站中的html表单。该表单是php处理的。请帮我修复php文件,以便在处理完表单后,php将用户返回到flash页面并重新加载html表单。我尝试在php中使用window.location发送到页面,但那样不起作用。它会导致在html代码区域(可能是框架,但我不确定)中出现白色矩形。如何只重新加载该html表单?我不想使用URL加载整个页面,因为那太慢了,而且我无法复制flash状态。顺便说一下,以下是简化版本的代码。
URL: http://www.wix.com/efficertain/efficertainaccounting/accounting 表单代码:
姓名
电话
最佳通话时间

PHP Code:

$mail_to = 'info@efficertain.ca';
$subject = 'Message from a site visitor '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_phone."\n";
$body_message .= 'Message: '.$field_when;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

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

if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
    alert('Thank you for the message. We will contact you shortly.');
    window.location = 'http://www.wix.com/efficertain/efficertainaccounting/accounting';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
    alert('Message failed. Please, send an email to info@efficertain.ca');
    window.location = 'http://www.wix.com/efficertain/efficertainaccounting/accounting';
</script>
<?php
}
?>

2个回答

0

在此处你不应该使用 window.location,因为它会重新加载整个浏览器窗口。尝试使用 document.location 并且你需要传递表单的 URL 而不是整个页面的 URL,因为你只想重新加载 iframe 的内容。所以根据上面的例子,你的 URL 将是 http://www.flashquix.com/embeds/fb4c83282b9342aa83952e74ad33dfdd?wrap=no&gzip=true&bg=transparent

document.location = 'http://www.flashquix.com/embeds/fb4c83282b9342aa83952e74ad33dfdd?wrap=no&gzip=true&bg=transparent';

谢谢bardiir。非常有效。现在我正在尝试获取表单中的URL并将其传输到php,因为php将与多个来源一起使用。但是无法正常工作。可能是初学者的语法问题。 - Paul

0

你已经在页面上添加了新内容...只需按照逻辑将该内容制作成表单即可。

else { ?>
<script language="javascript" type="text/javascript">
    alert('Message failed. Please, send an email to info@efficertain.ca');
</script>
// INSERT YOUR FORM HTML HERE AND YOU'RE GOOD TO GO

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接