หน้าต่างย่อยแบบอินไลน์ (Inline sub window) คือ iframe และคุณสามารถรวมได้โดยใช้แท็ก <iframe>
แอตทริบิวต์ของ <iframe>
| แอตทริบิวต์ | ค่า | คำอธิบาย |
|---|---|---|
| align | left, right, top, middle, bottom | Deprecated - จัดตำแหน่ง iframe ตามข้อความรอบข้าง |
| frameborder | 1, 0 | Deprecated - แสดง/ซ่อนขอบเฟรม (ใช้ CSS border แทน) |
| height | pixels | ความสูงของ inline frame |
| longdesc | URL | URL คำอธิบายยาวของเนื้อหาเฟรม |
| marginheight | pixels | ระยะห่างบน-ล่างระหว่างขอบและเนื้อหาเฟรม |
| marginwidth | pixels | ระยะห่างซ้าย-ขวาระหว่างขอบและเนื้อหาเฟรม |
| name | text | ชื่อของเฟรม (ใช้กับ target ของ link/form) |
| sandbox | "", allow-forms, allow-same-origin, allow-scripts, allow-top-navigation | เปิดใช้ข้อจำกัดเพิ่มเติมสำหรับความปลอดภัย |
| scrolling | yes, no, auto | Deprecated - การทำงานของ scrollbar (ใช้ CSS overflow แทน) |
| seamless | seamless | Deprecated - ทำให้ iframe ดูเหมือนเป็นส่วนของเอกสารหลัก |
| src | URL | ตำแหน่งไฟล์เนื้อหาเฟรม |
| srcdoc | HTML_code | ระบุเนื้อหา HTML โดยตรงใน iframe |
| width | pixels | ความกว้างของ inline frame |
ตัวอย่าง
คุณสามารถลองรันโค้ดต่อไปนี้เพื่อสร้าง inline frame:
<!DOCTYPE html>
<html>
<head>
<title>HTML iframe Tag</title>
</head>
<body>
<iframe src="https://www.tutorialspoint.com/index.htm" width="100%"></iframe>
</body>
</html>
แนวทางปฏิบัติด้านความปลอดภัย: เสมอใช้ sandbox และ allow-same-origin allow-scripts ตามต้องการ ไม่ควรใช้ sandbox="" ว่างๆ หากต้องการให้สคริปต์ทำงาน