Androidブラウザでviewportのwidth指定

参考
http://sp.vitalify.jp/archives/?p=375

viewportの設定と、アンカーでのリンクのずれを直す

[sourcecode language=”java”]
$(document).ready(function() {

var portraitWidth,landscapeWidth;

$(window).bind("resize", function(){

if(Math.abs(window.orientation) === 0){
if(/Android/.test(window.navigator.userAgent)){
if(!portraitWidth)portraitWidth=$(window).width();
}else{
portraitWidth=$(window).width();
}
$("html").css("zoom" , $(window).width/320 );
}else{
if(/Android/.test(window.navigator.userAgent)){
if(!landscapeWidth)landscapeWidth=$(window).width();
}else{
landscapeWidth=$(window).width();
}
$("html").css("zoom" , $(window).width/320 );
}

}).trigger("resize");

});

$(window).bind(‘resize load’, function(){
var phoneW;
if(navigator.userAgent.indexOf(‘iPhone’) < 0){
phoneW = 640;
}else{
phoneW = 320;
}
$("html").css("zoom", $(window).width()/phoneW );
});

[/sourcecode]