HTML <button> Thuộc tính mục tiêu biểu mẫu
Thí dụ
Một biểu mẫu có hai nút gửi. Nút gửi đầu tiên gửi dữ liệu biểu mẫu với đích mặc định ("_self") và nút thứ hai gửi dữ liệu biểu mẫu đến một cửa sổ mới (target = "_ blank"):
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<button type="submit" >Submit</button>
<button type="submit" formtarget="_blank">Submit to a new window</button>
</form>
Định nghĩa và Cách sử dụng
Thuộc formtarget
tính chỉ định nơi hiển thị phản hồi sau khi gửi biểu mẫu. Thuộc tính này ghi đè thuộc tính của biểu mẫu target
.
Thuộc formtarget
tính chỉ được sử dụng cho các nút có
type="submit"
.
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Attribute | |||||
---|---|---|---|---|---|
formtarget | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |
Cú pháp
<button type="submit" formtarget="_blank|_self|_parent|_top|framename">
Giá trị thuộc tính
Value | Description |
---|---|
_blank | Loads the response in a new window/tab |
_self | Loads the response in the same frame (this is default) |
_parent | Loads the response in the parent frame |
_top | Loads the response in the full body of the window |
framename | Loads the response in a named iframe |
❮ Thẻ HTML <button>