1
We know that by property target
HTML form we can tell if the request window will open in the same window or in a new.
When using target="_blank"
a new window is opened, it makes sense even by the name _blank
, :-)
We have the following options
_self
: Load the response in the same browsing context as the current one. This is the default value if the attribute is not specified._blank
: Load the response in a new incognito context._parent
: Loads the answer in the context of the current parent navigation. If there is no parent, this option has the same behavior as_self
._top
: Load the response in the context of root navigation (i.e., the browsing context that is ancestral to the current one and has no parent). If there is no parent, this option has the same behavior as_self
.
But I came up with a question that I did not find on the web, at least in a clear way. I could use the window.open
and determine the same window always, but then we have the problem of blocking "popups" :-(
Also in my layout I didn’t see how to use a <iframe>
, which would be another window reuse option, as I need it to be shown in another window.
Common example:
<form id="MeuForm" action="pagina.php" target="_blank">
<input type="text" name="pesquisa" value=""/>
<input type="submit" value="Relatorio"/>
</form>
Sending the form will open a new tab in the browser at each request, "filling" windows to the user screen and consuming unnecessary resources, because the need is that it sees only one report at a time.
Is it possible to reuse the same window (which has already been opened in _blank
) to display the next results of a request for a <form>
?
I can’t believe I did it, :-) after reading about the target I ended up doing a test on my code and decided to put target="report" on the property... and to my surprise (but not so much) the request is always open in the same window... is that a behavior of all browsers? Tested in Chrome, Firefox and Safari, the problem with Safari is that it doesn’t bring the window for shipping like Firefox and Chrome.
– Marcelo