Latest web development tutorials

HTML DOM Form target property

Form Object Reference Form Object

Definition and Usage

target property is used to set or return target attribute values ​​form form.

Open the target attribute specifies the form of action-URL where.

grammar

formObject.target=value

target attribute can have the following values:

描述
_blank 打开新窗口
_self 在相同的框架或窗口中载入目标文档
_parent 把文档载入父窗口或包含了超链接引用的框架的框架集
_top 把文档载入包含该超链接的窗口,取代任何当前正在窗口中显示的框架
framename 在同一个名称的frame框架打开窗口


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support target attribute


Examples

Examples

Return to open 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>

Above script output:

_blank

try it"


Form Object Reference Form Object