最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reload parent page after submit in iframe - Stack Overflow

programmeradmin2浏览0评论

I have the same issue as in this question. (which has no correct answer, I just test all of them):

Reload page after submit in iframe (javascript/jquery)

What I need is very well explained there.

I have a button in a form, all this inside an iframe (same domain) and I need to reload the parent page, just after the iframe has made the whole submit process, I do not want to "cut" it or interrupt it.


UPDATE: I kept searching and I found this. But I can't understand the code in the correct answer, is that for asp? I'm on PHP.

Reload page after submit in iframe (javascript/jquery)

.html

I have the same issue as in this question. (which has no correct answer, I just test all of them):

Reload page after submit in iframe (javascript/jquery)

What I need is very well explained there.

I have a button in a form, all this inside an iframe (same domain) and I need to reload the parent page, just after the iframe has made the whole submit process, I do not want to "cut" it or interrupt it.


UPDATE: I kept searching and I found this. But I can't understand the code in the correct answer, is that for asp? I'm on PHP.

Reload page after submit in iframe (javascript/jquery)

http://dotnetspidor.blogspot.mx/2011/07/refresh-parent-page-partially-from.html

Share Improve this question edited Apr 22, 2022 at 13:51 S. Dre 7011 gold badge8 silver badges19 bronze badges asked Dec 10, 2013 at 22:49 Moncho ChavezMoncho Chavez 6942 gold badges11 silver badges31 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 8

Once the form has been submitted in the iframe

<form method="POST" action="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>";

?>

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.

all that you need to do is add the below line,

window.parent.location.reload();

at the end of the function that is called onclick of your submit button.

发布评论

评论列表(0)

  1. 暂无评论