对于 VML 检测,以下是谷歌地图的作用(搜索“ function Xd
”):
function supportsVml() {
if (typeof supportsVml.supported == "undefined") {
var a = document.body.appendChild(document.createElement('div'));
a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
var b = a.firstChild;
b.style.behavior = "url(#default#VML)";
supportsVml.supported = b ? typeof b.adj == "object": true;
a.parentNode.removeChild(a);
}
return supportsVml.supported
}
我明白你对 FF 的意思:它允许创建任意元素,包括 vml 元素 ( <v:shape>
)。看起来是对adjacency属性的测试,可以判断创建的元素是否真的被解释为vml对象。
对于 SVG 检测,这很好用:
function supportsSvg() {
return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0")
}