How to do that when submitting a form within an iframe, the page that has iframe is redirected?

Asked

Viewed 2,072 times

4

I’m creating a page that works like this:

The person accesses a registration page, and within that page there is a iframe with the registration form. When a person clicks inside the iframe in register it redirects to another page I created. Only the new page appears inside the iframe, and I want the page that contains the iframe be redirected to sucesso.html.

I’ve tried using something like target="":

<form id="form1" target="_self" method="post" action="concluido.php">

But it went on the same way.

How to have the window redirected rather than the contents of the iframe?

  • Forehead with target="_blank", otherwise you can do with JS on onsubmit open a new window.

  • I don’t want it to open in a new window, I want when you click INSIDE THE IFRAME in Register, the page that has iframe is redirected to success.html

2 answers

2

If you want to open a new page, you can put an instruction on your page contained in the iframe so that when you finish receiving PHP it makes a js call:

<script>
    window.open("suaPagina.php");
</script>

If you want to update the page to the form Ubmit you can do so:

<form action="login.php" method="post" target="_blank"></form>

Refatorando here: If you want Parent(parent page) to be fully updated after Submit, you can do it in php by adding a head after post manipulation:

<?php    
    header('Localização: suaPagina.php');    
?>

Can do writing a js after handling:

<script>
    window.location = "suaPagina.php";

</script>

Or you can use the form tag by submitting the entire screen:

<form action="login.php" method="post" target="_parent"></form>
  • I don’t want it to open in a new window, I want when I click INSIDE THE IFRAME in Register, the page that has the iframe is

  • Edited there.. had started writing the reply to update the Parent, but when I read the previous title Abrir uma nova página, I changed the content of the answer... I hope you answer...

1

You can use target="_parent" if you have a link that when clicked should open on the page that contains the iframe.

If you want to open one url specific on the page that contains the iframe you can use window.parent.location so, for example:

document.querySelector('a').addEventListener('click', function(e){
  e.preventDefault;
  window.parent-location = this.href;
});

Example online here

  • How would it look to adapt in: <input name="avanca" type="submit" id="btn" value="Cadastrar" style="&#xA; position: relative;&#xA; left: 200px;&#xA; margin: 5px;&#xA; padding: 10px;&#xA;">

  • @Alexandrelopes where is the information of url? if it is that of <form> you can use target="_parent" in form.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.