| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<title>Element.getAttribute ("q:name")</title> |
| 5 |
</head> |
| 6 |
<body> |
| 7 |
<h1><code><var>Element</var>.getAttribute ("q:name")</code></h1> |
| 8 |
|
| 9 |
<p>Does <code><var>Element</var>.getAttribute |
| 10 |
("<var>prefix</var>:<var>localName</var>")</code> match to |
| 11 |
attribute <code>(<var>namespaceURI</var>, |
| 12 |
<var>prefix</var>, <var>localName</var>)</code>?</p> |
| 13 |
|
| 14 |
<p>Result: <span id="result">NOT EXECUTED</span></p> |
| 15 |
|
| 16 |
<script> |
| 17 |
window.onload = function () { |
| 18 |
var result = document.getElementById ("result"); |
| 19 |
result.firstChild.data = "FAILED"; |
| 20 |
|
| 21 |
var el = document.createElement ("span"); |
| 22 |
el.setAttributeNS ("http://q.test/", "q:name", "MATCH"); |
| 23 |
|
| 24 |
var attr = el.getAttribute ("q:name"); |
| 25 |
|
| 26 |
if (attr == null) { |
| 27 |
result.firstChild.data = "NO MATCH (null)"; |
| 28 |
} else if (attr == "") { |
| 29 |
result.firstChild.data = "NO MATCH (empty)"; |
| 30 |
} else { |
| 31 |
result.firstChild.data = attr; |
| 32 |
} |
| 33 |
}; |
| 34 |
</script> |
| 35 |
|
| 36 |
</body> |
| 37 |
</html> |