MathML support test
Trying to detect MathML.
by marcoos
HTML
<div></div>
JavaScript
function hasMathML() {
var mathNS = 'http://www.w3.org/1998/Math/MathML';
var math = document.createElementNS(mathNS, 'math');
var mi = document.createElementNS(mathNS, 'mi');
mi.appendChild(document.createTextNode('x'));
document.body.appendChild(math);
math.appendChild(mi);
var supports = 'italic' == window.getComputedStyle(mi).
getPropertyValue('font-style');
document.body.removeChild(math);
return supports;
}
document.querySelector('div').innerHTML =
hasMathML() ? "You've got MathML :)" : "No MathML support :(";