2

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!

1 Answer 1

6

try 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?

Sign up to request clarification or add additional context in comments.

1 Comment

I wanted to add a missing curly brace but I can't because an edit has to be at least 6 characters :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.