prefix

書式

obj.prefix

対応

[IE5〜][Firefox 1〜][Safari 1〜][Opera 8〜][Netscape 6〜]

説明

名前空間の識別子を返します。識別子がない場合はnullを返します。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=shift_jis">
<title>Sample</title>
<script type="text/javascript"><!--
function checkPrefix() {
var divObj = document.getElementById("pBox");
alert(divObj.prefix);
}
// --></script>
</head>
<body>
<h1>prefix</h1>
<form>
<input type="button" id="myButton" value="Click" onClick="checkPrefix()">
</form>
<div id="pBox">Sample text</div>
</body>
</html>

サンプルコード2 [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=shift_jis">
<title>Sample</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
function checkPrefix() {
new Ajax.Request("sample.xml", { method: "get",
onComplete: function(httpObj) {
var xmlDoc = httpObj.responseXML;
alert(xmlDoc);
var nameTag = xmlDoc.getElementsByTagName("name");
alert(nameTag[0].firstChild.nodeValue);
alert(nameTag[0].prefix);
}
});
}
// --></script>
</head>
<body>
<h1>prefix</h1>
<form>
<input type="button" id="myButton" value="Click" onClick="checkPrefix()">
</form>
</body>
</html>

■XMLデータ
<?xml version="1.0" encoding="utf-8"?>
<list xmlns:ls="http://www.openspc2.org/ns/sample">
<user>
<ls:name>KF</ls:name>
<id>123</id>
</user>
<user>
<ls:name>TT</ls:name>
<id>987</id>
</user>
</list>