且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在iframe中提交后重新加载父页面

更新时间:2022-02-02 21:42:08

表单已在iframe中提交

Once the form has been submitted in the iframe

<form method="POST" action="getForm.php">

页面重新加载到getForm.php中,然后在该文件中执行

The page reloads into getForm.php, and in that file you do:

<?php

    $input = $_POST['input'];
    // process form and do your stuff etc

    echo "<!DOCTYPE html>";
    echo "<head>";
    echo "<title>Form submitted</title>";
    echo "<script type='text/javascript'>window.parent.location.reload()</script>";
    echo "</head>";
    echo "<body></body></html>";

?>

这将在提交表单后重新加载父页面,现在唯一的问题是,如果仍然要重新加载父页面,为什么要通过iFrame提交.

and that would reload the parent page after the form has submitted, now the only question is, why are you submitting through an iFrame if you're going to reload the parent page anyway.