แบบฟอร์ม ปุ่มคุณสมบัติEnctype
ตัวอย่าง
ส่งคืนวิธีการเข้ารหัสข้อมูลแบบฟอร์มก่อนส่งไปยังเซิร์ฟเวอร์:
var x = document.getElementById("myBtn").formEnctype;
ความหมายและการใช้งาน
ชุดคุณสมบัติ formEnctype หรือคืนค่าของแอตทริบิวต์ formenctype ของปุ่ม
แอตทริบิวต์ formnctype ระบุว่าควรเข้ารหัสข้อมูลแบบฟอร์มอย่างไรก่อนส่งไปยังเซิร์ฟเวอร์ แอตทริบิวต์นี้จะแทนที่แอตทริบิวต์ enctype ของแบบฟอร์ม
แอตทริบิวต์ formnctype ใช้สำหรับปุ่มที่มี type="submit" เท่านั้น
หมายเหตุ:แอตทริบิวต์ formnctype ใหม่สำหรับองค์ประกอบ <button> ใน HTML5
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
formEnctype | Yes | 10.0 | Yes | Yes | Yes |
ไวยากรณ์
ส่งกลับคุณสมบัติ formEnctype:
buttonObject.formEnctype
ตั้งค่าคุณสมบัติ formEnctype:
buttonObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
application/x-www-form-urlencoded | All characters are encoded before sent (this is default) |
multipart/form-data | No characters are encoded. This value is required when you are using forms that have a file upload control |
text/plain | Spaces are converted to "+" symbols, but no special characters are encoded |
รายละเอียดทางเทคนิค
คืนมูลค่า: | สตริงที่แสดงถึงประเภทของเนื้อหาที่ใช้ในการส่งแบบฟอร์มไปยังเซิร์ฟเวอร์ |
---|
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนค่าของแอตทริบิวต์ formnctype ของปุ่มจาก "text/plain" เป็น "application/x-www-form-urlencoded":
document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded";
ตัวอย่าง
อีกตัวอย่างหนึ่งในการส่งคืนคุณสมบัติ formEnctype:
var x =
document.getElementById("myBtn").formEnctype;
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML: HTML <button> formnctype แอตทริบิวต์
❮ ปุ่มวัตถุ