DOM Entity物件systemId屬性

2019-10-16 23:19:13

DOM Entity物件systemId屬性返回關聯實體的系統識別符號或返回null

語法

以下是systemId屬性的使用語法。

document.doctype.systemId;

範例

檔案:notation.xml 的內容如下 -

<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<address id = "firstelement">
   <name>Tianya Su</name >
   <company>Yiibai Tutorial</company>
   <phone>(0898) 61234567</phone>
</address>

以下範例演示了systemId屬性的用法 -

<!DOCTYPE html>
<html>
   <meta charset="utf-8"/>
    <head>
      <script>
         function loadXMLDoc(filename) {
            if (window.XMLHttpRequest) {
               xhttp = new XMLHttpRequest();
            } else // code for IE5 and IE6 
            {
               xhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhttp.open("GET",filename,false);
            xhttp.send();
            return xhttp.responseXML;
         }
      </script>
   </head>
   <body>
      <script>
         xmlDoc = loadXMLDoc("/notation_xhtml.xml");
         document.write("<b>SystemId :</b> "+xmlDoc.doctype.systemId);
      </script>
   </body>
</html>

運算上面範例程式碼,得到以下結果 -