如何在不刷新整个页面重置视口比例?比例、页面、如何在

2023-09-05 00:03:04 作者:微笑、不失礼

我有一个网页,有视meta标签设置为true的用户可升级的属性(Safari参考, Android的参考)。因此,用户的浏览器识别的属性(如移动Safari浏览器,Android浏览器)可以捏缩放页面。然而,存在刷新大多数使用AJAX页面,但不执行刷新整个页面的链接。我想视口缩放重置为使用JavaScript的初始值。但我无法弄清楚如何做到这一点。

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.

唯一的解决办法似乎是一个完整的页面刷新。任何人都知道一个更好的方式?

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

感谢。

推荐答案

pretty的简单交易使用jQuery来设置视口:

Pretty simple deal to set the viewport using jQuery:

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

这使用jQuery移动作为一个框架,适用于移​​动Safari浏览器。

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