DOM DocumentType对象publicId属性返回外部子集的公共标识符。
语法
以下是publicId属性的使用语法。
document.doctype.publicId;
示例
文件: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>
以下示例演示了publicId属性的用法 - 
<!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>publicid :</b> "+xmlDoc.doctype.publicId);
      </script>
   </body>
</html>
执行上面示例代码,得到以下结果 -

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