获取元视口标签在桌面上工作 [英] Get meta viewport tag to work on desktop
问题描述
我创建了一个在桌面上启用元视口标签的脚本。但是我似乎不能从视口标签获得指定的宽度。我目前有这个:
I have created a script that enables the meta viewport tag on desktop. However I do not seem to be able to get the specified width from the viewport tag. I currently have this:
var viewportcontent = $( "#myviewport" ).attr('content');
var viewportcontents = viewportcontent.split(",");
//if it starts with 'width='
for (var i = 0; i < viewportcontents.length; i++) {
if(viewportcontents[i].lastIndexOf('width=', 0) === 0) {
var wspec = viewportcontent[i].substring(6);
}
}
问题是这似乎确定,工作。帮帮我!我一直在寻找这个太久了!
The problem is that this seems ok, but does not work. Help! I have been looking at this for too long!
网站: http://apps.usecue.com/viewport/viewport_tag.html (静态宽度,工作)
Website: http://apps.usecue.com/viewport/viewport_tag.html (static width, working)
Codepen: http://codepen.io/anon/pen/aZdMGa (动态宽度,不工作)
Codepen: http://codepen.io/anon/pen/aZdMGa (dynamic width, not working)
推荐答案
对不起,原来是一个错字! var wspec = viewportcontent [i] .substring(6);
必须 var wspec = viewportcontents [i] .substring(6) code>。我必须记住使用更好的变量名称!
Sorry guys... It turned out to be a typo! var wspec = viewportcontent[i].substring(6);
had to be var wspec = viewportcontents[i].substring(6);
. I have to remember to use better variable names!!!
此处的工作版本: http:// codepen。 io / anon / pen / GqoeYJ
这篇关于获取元视口标签在桌面上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!