Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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

Thanks.

like image 874
Mzzzzzz Avatar asked Mar 21 '11 16:03

Mzzzzzz


1 Answers

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.

like image 68
Brandon Avatar answered Nov 13 '22 05:11

Brandon