如何在没有完整页面刷新的情况下重置视口缩放?

[英]How to reset viewport scaling without full page refresh?


I have a web-page that has the "user-scalable" attribute of the viewport meta tag set to true (Safari reference, Android reference). So users with browsers that recognize the attribute (such as Mobile Safari, Android Browser) can pinch to scale the page. However, there is a link that refreshes most of the page using AJAX, but does not perform a full page refresh. I'd like to reset the viewport scaling to the initial value using JavaScript. But I can't figure out how to do this.

我有一个网页,其视口元标记的“用户可伸缩”属性设置为true(Safari参考,Android参考)。因此,具有识别该属性的浏览器的用户(例如Mobile Safari,Android Browser)可以缩小以缩放页面。但是,有一个链接使用AJAX刷新大部分页面,但不执行整页刷新。我想使用JavaScript将视口缩放重置为初始值。但我无法弄清楚如何做到这一点。

The only solution seems to be a full page refresh. Anyone know of a better way?

唯一的解决方案似乎是整页刷新。谁知道更好的方法?

Thanks.

2 个解决方案

#1


1  

Pretty simple deal to set the viewport using jQuery:

使用jQuery设置视口非常简单:

$('meta[name=viewport]').attr('content', 'width=device-width, initial-scale=1');

This works on Mobile Safari using jQuery Mobile as a framework.

这适用于使用jQuery Mobile作为框架的Mobile Safari。

#2


0  

After loading the page most browsers will ignore changing the viewport. Opera will do it, Fennec and Android won't, if I remember my own tests with a faked body correctly.

加载页面后,大多数浏览器将忽略更改视口。 Opera会做到这一点,Fennec和Android不会,如果我记得我自己的假身体测试。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/03/21/54484c633e6eb2238cfed1d95b4b3024.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告