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?