Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
some androids can't handle meta viewport width=number.
/*
There's <meta name="viewport" content="width=480" /> in html then...
*/
// handle Android's viewport
(function($, undefined){
$.browser.android = /android/i.test(navigator.userAgent);
if(!$.browser.android){
return;
}
var timer;
var $w = $(window);
var $html = $('html');
var $meta = $('meta[name=viewport]');
function refresh(){
if(timer){
return;
}
$html.css('visibility','hidden');
$meta.attr('content', 'width=device-width, heigh=device-height');
timer = setTimeout(function(){
var h = $w.height();
$meta.attr('content', 'width=480, height=' + h);
$html.css({
visibility: 'visible',
height: h
});
timer = null;
// do something here if you need to refresh UI or something
// $(':ui-iscroll').iscroll('refresh');
},500);
}
$w.bind('orientationchange load', refresh);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment