Load Target from Iframe into a new Main Window Tab

0

I have an HTML page that incorporates a code iframe , my problem is that this embedded code has a form, which when completed needs to be opened in a new tab, however this tab is opened inside div where the iframe is embedded, I need this new tab to open in the main window.

Important

The iframe page (embedded page) is in the same domain as the main page and I have access to it, so I can put any jquery / javascript code in it.

Iframe code:

<iframe src="http://siteexemplo.com.br/index2.php"scrolling="no" style=" width: 100%; height: 100px; overflow: hidden;"></iframe>

This iframe page contains a form with the following HTML.

Embedded HTML page

<form class="form-signin" action="validacao.php" method="post" target="_self">
    <div style="width:60%; float:left">
        <input type="password" name="senha" id="inputPassword" style="height:47px" class="form-control" placeholder="Senha" required>
    </div>
    <div style="width:39%; float:right">
        <button class="btn btn-lg btn-primary btn-block" type="submit" ><a style="color:#ffffff; text-decoration:none" >Visualizar</a></button>
    </div>

</form>

Can anyone help me?

    
asked by anonymous 13.03.2017 / 15:57

2 answers

0

One way to solve this is to pass the URL of what you want to open in the other window, the script takes the content of the page and sends it to the browser, then you will have the desired content on the page, but the address from another site, an example in php might be:

link

reference and further explanation in the original English text: link

    
13.03.2017 / 18:00
0

Man, just to be sure: have you tried changing the target of the form inside the iframe to "_blank"? It would look like this:

<form class="form-signin" action="validacao.php" method="post" target="_blank">
  ...
</form>

Not working, you can capture the form submission with the .onsubmit or $().submit event and go up to the parent frame. For this, get the object window.parent that you will use to open the new tab. It would look something like

window.parent.open("endereço do GET", "_blank")

Of course, because your form is POST, you may need to let the form run what it needs and pass a temporary GET address. In case, as it seems to be authentication, the server response would arrive by the iframe itself with the session cookie, so it would be okay to include the JS code to execute only on the POST response.

    
13.03.2017 / 18:46