1

我的页面在横向模式下工作正常,但在纵向模式下,我必须缩小一点,然后才能适应屏幕。所以我想编写一个JavaScript,当我以纵向模式旋转时缩小或缩小我的页面

if(navigator.platform == 'iPad') {
        window.onorientationchange = function () {
            var orientation = window.orientation;
            // Look at the value of window.orientation:
            if (orientation === 0) {
                alert("iPad is in Portrait mode.");
                 // my code goes here 
                var viewportmeta = document.querySelector('meta[name="viewport"]');
                viewportmeta.content = 'width = 1003,initial-scale = 0.5, maximum-scale = 2.0, minimum-scale=0.7';

            }
            else if (orientation === 90) {
                // iPad is in Landscape mode. The screen is turned to the left.
            }
            else if (orientation === -90) {
                // iPad is in Landscape mode. The screen is turned to the right.
            }
        }

    }

它看起来不错scale = 0.5;

4

1 回答 1

0

只是我用过<meta name="viewport" content="width=640"> ,每一个都解决了

于 2012-09-28T19:49:17.500 回答