Form targetProperty

Form 对象参考手册Form Object

Definition and Usage

The target property is used to set or return the value of the target attribute of the form.

The target attribute specifies where to open the action-URL in the form.

Syntax

formObject.target=value

The target attribute can have the following values:

Value Description
_blank Open a new window
_self Load the target document in the same frame or window
_parent Load the document into the parent window or the frameset that contains the frame with the hyperlink reference
_top Load the document into the window containing the hyperlink, replacing any frames currently displayed in the window
framename Open a window in a frame with the same name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the target attribute.


Examples

Example

Return the action URL:

<html>
<body>

<form id="frm1" action="form_action.html" target="_blank">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>

<script>
document.write(document.getElementById("frm1").target);
</script>

</body>
</html>

Output of the above script:

_blank

Try it yourself »


Form 对象参考手册Form Object Other Extensions