HTML <button> แอตทริบิวต์รูปแบบเป้าหมาย
ตัวอย่าง
แบบฟอร์มที่มีปุ่มส่งสองปุ่ม ปุ่มส่งปุ่มแรกส่งข้อมูลในแบบฟอร์มโดยมีเป้าหมายเริ่มต้น ("_self") และปุ่มที่สองส่งข้อมูลแบบฟอร์มไปที่หน้าต่างใหม่ (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>
ความหมายและการใช้งาน
แอตทริบิวต์formtarget
ระบุตำแหน่งที่จะแสดงการตอบกลับหลังจากส่งแบบฟอร์ม แอตทริบิวต์นี้จะแทนที่แอตทริบิวต์ของแบบtarget
ฟอร์ม
คุณลักษณะformtarget
นี้ใช้สำหรับปุ่มที่มี
type="submit"
.
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนแอตทริบิวต์อย่างเต็มที่
Attribute | |||||
---|---|---|---|---|---|
formtarget | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |
ไวยากรณ์
<button type="submit" formtarget="_blank|_self|_parent|_top|framename">
ค่าแอตทริบิวต์
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 |
❮ แท็ก HTML <button>