简体   繁体   中英

jquery resize to mobile window iphone/android

i was wondering if there were any methods that would allow for my webpage to adjust to an iphone's or android's screen? i read about $(window).resize in What does $(window).resize do? JQuery Mobile , i read the documentation and am still confused. can someone provide an example for this?

$(window).resize(...) binds a callback for the resize event or triggers this event.

Bind a callback function, if the users resizes the browser window:

$(window).resize(function() {
    alert('resize handler called');
});

If you want to call all listeners manually (without any parameters):

$(window).resize();

=== UPDATE ===

Also see this example .

=== UPDATE ===

I don't think that you can resize the window, but you can change the zoom level by changing the viewport scale (untested):

function changeZoomLevel(iScale) {
    var sViewport = '<meta name="viewport" content="width=device-width, initial-scale=' + iScale + '">';
    var jViewport = $('meta[name="viewport"]');
    if (jViewport.length > 0) {
        jViewport.replaceWith(sViewport);
    } else {
        $('head').append(sViewport);
    }
}

var iScale = 0.5 // set or calculate a zoom value between 0 and 1
changeZoomLevel(iScale);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM