javascript - How to read the property values of the viewport meta tag? -
i have tried:
var viewportelement = document.queryselector('meta[name="viewport"]'), viewport = {}; if (viewportelement) { viewportelement.content.split(',').foreach(function (property) { property = property.split('='); viewport[property[0]] = property[1]; }); } console.log(viewport);
it give expected result:
object {width: "320", user-scalable: "no"}
however, not sure if reading values of these properties tag attribute value right approach. expecting these properties hiding somewhere under window
?
javascript meta
No comments:
Post a Comment