[英]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? 我想知道是否有任何方法可以让我的网页适应iPhone或Android的屏幕? i read about $(window).resize in What does $(window).resize do?
我在$(window).resize中做了什么来读取$(window).resize? JQuery Mobile , i read the documentation and am still confused.
JQuery Mobile ,我阅读了文档,但仍然感到困惑。 can someone provide an example for this?
有人可以为此提供一个例子吗?
$(window).resize(...)
binds a callback for the resize event or triggers this event. $(window).resize(...)
绑定resize事件的回调或触发此事件。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.