开发者

How to reset viewport scaling without full page refresh?

开发者 https://www.devze.com 2023-02-18 22:29 出处:网络
I have a web-page that has the \"user-scalable\" attribute of the viewport meta tag set to true (Safari reference,开发者_JAVA技巧 Android reference).So users with browsers that recognize the attribute

I have a web-page that has the "user-scalable" attribute of the viewport meta tag set to true (Safari reference,开发者_JAVA技巧 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?

Thanks.


Pretty simple deal to set the viewport using jQuery:

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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号