JavaScript對W3C DOM模版的支援情況詳解

來源:互聯網
上載者:User

        本文件物件模型允許訪問所有的文檔內容和修改,由全球資訊網協會(W3C)規範。幾乎所有的現代瀏覽器都支援這種模式。

        在W3C DOM規範的大部分傳統DOM的功能,而且還增加了新的重要的功能。除了支援forms[ ], images[ ]和文檔對象的其它數組屬性,它定義了方法,使指令碼來訪問和操縱的任何文件項目,而不只是專用元件狀的表單和映像。
文件屬性在W3C DOM:

        此模型支援所有傳統DOM提供的屬性。此外,這裡是文件屬性,可以使用W3C DOM訪問列表:

文檔方法在W3C DOM:

此模型支援所有傳統DOM提供的方法。此外,這裡是由W3C DOM支援的方法列表:

樣本:

這是(訪問和設定)使用W3C DOM文件項目很容易操縱。可以使用任何類似 getElementById,getElementsByName,orgetElementsByTagName 方法。

下面是訪問使用W3C DOM方法文件屬性的一個例子:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 <html> <head> <title> Document Title </title> <script type="text/javascript"> <!-- function myFunc() { var ret = document.getElementsByTagName("title"); alert("Document Title : " + ret[0].text );   var ret = document.getElementById("heading"); alert(ret.innerHTML ); } //--> </script> </head> <body> <h1 id="heading">This is main title</h1> <p>Click the following to see the result:</p>   <form id="form1" name="FirstForm"> <input type="button" value="Click Me" onclick="myFunc();" /> <input type="button" value="Cancel"> </form>   <form d="form2" name="SecondForm"> <input type="button" value="Don't ClickMe"/> </form>   </body> </html>

注意: 這個例子的形式和內容等返回對象,我們將不得不使用未在本教程中討論這些對象的屬性來訪問它們的值。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.