Specify a Target for the Form Response

Description

The default behavior of a browser is to replace the page with the response the server.

You can change this behavior by using the target attribute on the form element.

This attribute works in the same way as the target attribute on the a element, and you can select from the range of targets.

  • _blank - Opens the server response in a new window (or tab)
  • _parent - Opens the server response in the parent frameset
  • _self - Opens the server response in the current window (which is the default behavior)
  • _top - Opens the server response in the full body of the window.
  • <frame> - Opens the server response in the specified frame

Example

The following code shows how to use the target attribute.


<!DOCTYPE HTML>
<html>
<body>
  <form target="_blank" 
        method="post" 
        action="http://example.com/form">
    <input autocomplete="on" name="fave" /> 
    <input name="name" />
    <button>Submit Vote</button>
  </form><!--  w w w .  ja  va 2 s  .co m-->
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed