IE4 DOM (Internet Explorer 4 Document Object Model) มีคุณสมบัติเอกสารเฉพาะตัวที่แตกต่างจาก W3C DOM ด้านล่างคือรายการหลัก:
ตารางคุณสมบัติ Document ของ IE4 DOM
| # | Property | คำอธิบาย | ตัวอย่าง |
|---|---|---|---|
| 1 | activeElement | อ่านอย่างเดียว (Read-only) อ้างอิง Element ที่กำลังมี Focus อยู่ (Input, Button, Link, ฯลฯ) | document.activeElement |
| 2 | all[] | อาร์เรย์ (Collection) ของ Element ทุกตัวในเอกสาร เข้าถึงได้ด้วย Index, ID, หรือ Name | document.all[0], document.all["myId"], document.all.myName |
| 3 | charset | Character Set ของเอกสาร (Read/Write) | document.charset = "UTF-8" |
| 4 | children[] | อาร์เรย์ของ HTML Elements ที่เป็น Direct Children ของ Document (ไม่รวม Text Nodes, Comments) - ต่างจาก all[] ที่รวมทุกอย่าง | document.children[0] (มักเป็น <html>) |
| 5 | defaultCharset | Default Character Set ของเอกสาร (Read-only) | document.defaultCharset |
| 6 | expando | Boolean: true=อนุญาตให้เพิ่ม Property ใหม่บน Client-side Objects, false=ห้าม (Default: true) | document.expando = false |
| 7 | parentWindow | อ้างอิง Window Object ที่มี Document นี้ (IE Specific) | document.parentWindow |
| 8 | selection | ออบเจกต์ Selection สำหรับจัดการข้อความที่เลือก (TextRange) | document.selection.createRange() |
| 9 | styleSheets[] | คอลเลกชัน StyleSheet Objects ในเอกสาร | document.styleSheets[0] |
| 10 | url | URL ของเอกสาร (Read-only) - เทียบเท่า document.URL ใน W3C | document.url |
| 11 | referrer | URL ของหน้าที่เชื่อมต่อมา (Read-only) | document.referrer |
| 12 | domain | Domain ของเอกสาร (ใช้สำหรับ Cross-frame Scripting) - สามารถตั้งค่าได้ (Relaxing) | document.domain = "example.com" |
| 13 | cookie | String: อ่าน/เขียน Cookie ของเอกสาร | document.cookie = "name=value" |
เมธอด (Methods) ที่เกี่ยวข้อง
document.all.tags(tagName)- คืน Collection ของ Element ตาม Tag Namedocument.all.item(name, index)- เข้าถึง Element ใน Collectiondocument.recalc()- บังคับคำนวณ Expression ใหม่ (IE Specific)document.createStyleSheet()- สร้าง StyleSheet ใหม่
การเข้าถึง Element ย่อย (Element Properties/Methods ใน IE4)
element.innerHTML/outerHTML- เนื้อหา HTML (IE พัฒนาเอง ก่อนเป็นมาตรฐาน)element.innerText/outerText- เนื้อหา Text (IE Specific, W3C ใช้textContent)element.insertAdjacentHTML(position, html)- แทรก HTML (BeforeBegin, AfterBegin, BeforeEnd, AfterEnd)element.contains(otherElement)- ตรวจสอบว่าเป็น Ancestor หรือไม่element.sourceIndex- Index ในdocument.all
สถานะปัจจุบัน
- ส่วนใหญ่ (activeElement, children, styleSheets, url, referrer, domain, cookie, innerHTML, insertAdjacentHTML, contains) **กลายเป็นมาตรฐาน W3C/DOM Living Standard** แล้ว
document.all,document.all.tags(),innerText,sourceIndex,parentWindow,selection(TextRange) **ยังคงเป็น IE-Specific / Legacy**- ไม่ควรใช้ในโค้ดใหม่ ใช้ W3C DOM Standard Methods แทน