hasAttributeNS

書式

obj.hasAttributeNS(namespace, attrName)

属性

パラメータ 内 容
namespace 名前空間識別子
attrName 属性名

対応

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

説明

指定された名前空間を持つ属性名が存在する場合はtrue、そうでない場合はfalseを返します。HTMLの場合は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 checkAttr() {
flag = document.body.hasAttributeNS(null, "bgcolor");
alert(flag);
flag = document.body.hasAttributeNS(null, "value");
alert(flag);
}
// --></script>
</head>
<body bgcolor="#fffff0">
<h1>hasAttributeNS</h1>
<form>
<input type="button" id="myButton" value="Click" onClick="checkAttr()">
</form>
</body>
</html>