Reputation: 707
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?
Upvotes: 0
Views: 5093
Reputation: 16115
$(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);
Upvotes: 2