这是一个用于检测浏览器中的 VML 支持的函数。它是 html 组件文件的一部分,用于为旧版本的 IE 提供边框半径和阴影功能。我想向我解释一下它的分步逻辑:
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
}
我感到困惑的地方:
- 什么是 supportVml.supported?这是一个变量吗,我没有看到它在文件中的其他任何地方声明...
- 什么是 url(#default#VML) 行为?
- supportsVml.supported 根据条件重新分配了一个新值,但我不知道是什么或为什么......
谢谢!