Understanding Form Tag’s Target Attribute

Posted on by By Nikhilesh, in Helical Insight, Miscellaneous | 0

form tag has a target attribute, which can be used the control the response after the form submission. target can take one the following values:

  • _blank: The response will be displayed in new tab/window
  • _self: The response will be displayed in same frame. This is the default value
  • _parent: The response will be displayed in parent frame.
  • _top: The response will be displayed in top frame.
  • framename: The response will be displayed in named iframe.

_parent, _top, framename are generally used with iframes. This can be used for our advantage.

For example we can trigger a download (which requires POST request) in same window without redirection.

<iframe name="download" style="display:none"></iframe>
<form method="POST" action="/path/to/download-service" target="download" style="display:none">
  <input type="hidden" name="somefield"  value="somevalue" >
</form>

Upon submission of this form the response will be directed to the iframe and the download will begin.

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments