我个人为此苦苦挣扎。但最终在一天结束时找到了答案。您可以在下面使用我的代码,它将显示 Modernizr 功能及其值的完整列表:
<script type="text/javascript">
$(document).ready(function () {});
</script>
<script type="text/javascript">
$(function () {
function ListAllMOdernizrFeatures() {
var TotalString = "Modernizr features<br><br>";
var arrModernizrFeatures = new Array();
for (var feature in Modernizr) {
if (typeof Modernizr[feature] === "boolean") {
console.log("Modernizr_" + feature + ": " + Modernizr[feature]);
arrModernizrFeatures.push("Modernizr." + feature + ": " + Modernizr[feature])
for (var subFeature in Modernizr[feature]) {
var ModernizrFeature = Modernizr[feature];
if (typeof ModernizrFeature[subFeature] === "boolean") {
arrModernizrFeatures.push("Modernizr." + feature + subFeature + ": " + ModernizrFeature[subFeature]);
}
}
}
}
arrModernizrFeatures.sort(); // in lexicographical order
for (var PropertyIterator = 0; PropertyIterator < arrModernizrFeatures.length; PropertyIterator++) {
TotalString += PropertyIterator + 1 + ". " + arrModernizrFeatures[PropertyIterator] + "<br>";
};
document.getElementById("ListFeatures").innerHTML = TotalString;
}
setTimeout(ListAllMOdernizrFeatures, 100);
});
</script>