Created
January 10, 2011 08:09
-
-
Save Takazudo/772523 to your computer and use it in GitHub Desktop.
some androids can't handle meta viewport width=number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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