HTML <เมนู>แท็ก
ตัวอย่าง
เมนูบริบทที่มีองค์ประกอบ <menuitem> ต่างกัน:
<menu type="context" id="mymenu">
<menuitem label="Refresh" onclick="window.location.reload();" icon="ico_reload.png">
</menuitem>
<menu label="Share on...">
<menuitem label="Twitter" icon="ico_twitter.png"
onclick="window.open('//twitter.com/intent/tweet?text='+window.location.href);">
</menuitem>
<menuitem label="Facebook" icon="ico_facebook.png"
onclick="window.open('//facebook.com/sharer/sharer.php?u='+window.location.href);">
</menuitem>
</menu>
<menuitem label="Email This Page"
onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
</menu>
ความหมายและการใช้งาน
แท็ก <menu> กำหนดรายการ/เมนูของคำสั่ง
แท็ก <menu> ใช้สำหรับเมนูบริบท แถบเครื่องมือ และสำหรับการแสดงรายการตัวควบคุมและคำสั่งแบบฟอร์ม
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนองค์ประกอบอย่างสมบูรณ์
Element | |||||
---|---|---|---|---|---|
<menu> | Not supported | Not supported | 8.0 (only context menus) |
Not supported | Not supported |
หมายเหตุ:แท็ก <menu> รองรับเฉพาะใน Firefox และใช้งานได้กับเมนูบริบทเท่านั้น
เคล็ดลับและหมายเหตุ
เคล็ดลับ:ใช้ CSS เพื่อจัดรูปแบบรายการเมนู
คุณลักษณะ
Attribute | Value | Description |
---|---|---|
label | text | Specifies a visible label for the menu |
type | list toolbar context |
Specifies which type of menu to display |
คุณสมบัติสากล
แท็ก <menu> ยังสนับสนุนGlobal Attributes ใน HTML
คุณสมบัติของเหตุการณ์
แท็ก <menu> ยังสนับสนุน แอตทริบิวต์เหตุการณ์ ในHTML
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML DOM: Menu Object
การตั้งค่า CSS เริ่มต้น
เบราว์เซอร์ส่วนใหญ่จะแสดงองค์ประกอบ <menu> โดยมีค่าเริ่มต้นดังต่อไปนี้:
menu {
display: block;
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}