admin管理员组文章数量:1316973
I made an app with phonegap. I didnt wantet to use media queries because so i had to change all parameters for diffrent viewport sizes. My idea was that i only change the inital scale of the html document with javascript. I know that i can change the initial scale with an function like i show here:
if (document.documentElement.clientWidth < 480) {
document
.querySelector("meta[name=viewport]")
.setAttribute('content', 'initial-scale=0.4', 'maximum-scale=0.4', 'width=768');
};
but i want that the initial scale is at an width of 320 pixel of the viewport 0 or in other words 100%. And at a viewport width of 720 (Galaxy S3) 110% or in other words initial scale of 0.1. For all the viewport sizes that lay between javascript should calculate the scale. I have no idea how to achieve this! Im very happy about every help! Hope you unterstood me, im from germany!
I made an app with phonegap. I didnt wantet to use media queries because so i had to change all parameters for diffrent viewport sizes. My idea was that i only change the inital scale of the html document with javascript. I know that i can change the initial scale with an function like i show here:
if (document.documentElement.clientWidth < 480) {
document
.querySelector("meta[name=viewport]")
.setAttribute('content', 'initial-scale=0.4', 'maximum-scale=0.4', 'width=768');
};
but i want that the initial scale is at an width of 320 pixel of the viewport 0 or in other words 100%. And at a viewport width of 720 (Galaxy S3) 110% or in other words initial scale of 0.1. For all the viewport sizes that lay between javascript should calculate the scale. I have no idea how to achieve this! Im very happy about every help! Hope you unterstood me, im from germany!
Share Improve this question asked Feb 21, 2013 at 19:20 Em StaEm Sta 1,70610 gold badges29 silver badges43 bronze badges1 Answer
Reset to default 6try this:
if (document.documentElement.clientWidth < 480) {
document.querySelector("meta[name=viewport]").setAttribute(
'content',
'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0');
}
Reference : Can I change the viewport meta tag in mobile safari on the fly?
本文标签: htmlChange initial scale with javascriptStack Overflow
版权声明:本文标题:html - Change initial scale with javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742019072a2414326.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论