0
I have the following code that opens a window popup janela.php
where I receive some data from the database:
<script>
$("button").click(function(){
window.open("janela.php", "_blank", "width=400, height=500");
});
</script>
In the window popup open, there is a button where the user clicks to send data to the main window (opener
), the one that opened the popup:
<script>
$(".botao").click(function(){
// outros códigos aqui que não vem ao caso
$(window.opener.document).find("#status").text("Salvo!");
});
</script>
Everything works perfectly.
Doubt: how to do that by clicking the button .botao
in popup
, the phocus pass from popup to the main window (opener
)? That is, by clicking the button, the popup move to the background and window opener
focus on the screen.
Would need something crossbrowser, that works in browsers Chrome, Firefox, Safari, Opera, IE (at least no 11) and Edge.
You can add focus with
.focus()
, but it is not possible to minimize the open window (at least Chrome). https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Note_on_use_of_window_open– Valdeir Psr
I tried but it didn’t work.
– Sam
I believe that doing this with Javascript is not possible. A possible alternative would be to create a custom modal on the page...
– Luiz Felipe