Dom-notation-publicid
提供:Dev Guides
DOM-表記オブジェクト属性-publicID
_Notation_の公開識別子。パブリック識別子が指定されていない場合はnull。
構文
_publicID_属性を使用するための構文は次のとおりです。
var pubid = document.doctype.publicId;
例
_notation_xhtml.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>
<name>Tanmay Patil</name >
<company>finddevguides</company>
<phone>(011) 123-4567</phone>
</address>
次の例は、_publicID_属性の使用方法を示しています-
<!DOCTYPE html>
<html>
<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("/dom/notation_xhtml.xml");
document.write("The publicId asscoiated with the notation is:"+ xmlDoc.doctype.publicId);
</script>
</body>
</html>
実行
このファイルを_notationattribute_publicidl_としてサーバーパスに保存します(このファイルとnotation.xmlはサーバーの同じパスにある必要があります)。 次のように出力を取得します-
The publicId asscoiated with the notation is: -//W3C//DTD XHTML 1.1//EN