我试过了:
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);
确实给出了预期的结果:
Object {width: "320", user-scalable: "no"}
但是,我不确定从tag属性值读取这些属性的值是否正确。我期待这些属性隐藏在window
下的某个地方?