Thuộc tính formtarget trên nút submit (<input type="submit"> hoặc <button type="submit">) chỉ định nơi hiển thị kết quả sau submit (tab mới, iframe, v.v.). Ghi đè target của form.
Chỉ hoạt động với type="submit" hoặc type="image".
| Giá trị | Mô tả |
|---|---|
_blank | Mở trong tab/cửa sổ mới |
_self | Mở trong cùng frame (mặc định) |
_parent | Mở trong frame cha |
_top | Mở trong toàn bộ cửa sổ (thoát iframe lồng) |
framename | Mở trong iframe có name tương ứng |
Ví dụ
<!DOCTYPE html>
<html>
<head>
<title>HTML formtarget attribute</title>
</head>
<body>
<form action="/new.php" method="get">
Tên học sinh<br><input type="text" name="name"/><br>
Môn học<br><input type="text" name="subject"/><br>
<input type="submit" value="Gửi">
<input type="submit" formtarget="_blank" value="Gửi (mở tab mới)">
</form>
</body>
</html>