DOM DocumentType对象systemId属性

DOM DocumentType对象systemId属性返回外部子集的系统标识符。 这可以是绝对URI或不是。

语法

以下是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>zaixian zaixian</company>
   <phone>(086) 123-4567890</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.xml");
         document.write("<b>SystemId :</b> "+xmlDoc.doctype.systemId);
      </script>
   </body>
</html>

执行上面示例代码,得到以下结果 -


上一篇: DOM DocumentType对象 下一篇: ProcessingInstruction对象