(function($){ /* * setFixViewPort * automatically set the view port. * @width viewport:device-width */ $.setFixViewPort = function(width){ var portraitWidth,landscapeWidth; var win = $(window); var ua = window.navigator.userAgent; var onResize = function(){ if(Math.abs(window.orientation) === 0){ if(/Android/.test(ua)){ if(!portraitWidth) portraitWidth = win.width(); }else{ portraitWidth = win.width(); } $("html").css("zoom" , portraitWidth/width ); }else{ if(/Android/.test(ua)){ if(!landscapeWidth) landscapeWidth=win.width(); }else{ landscapeWidth=win.width(); } $("html").css("zoom" , landscapeWidth/width ); } }; win.bind("resize",onResize); onResize(); }; /* * hideLocationBar * */ $.hideLocationBar = function(){ $.event.add(window,"load",function(){ scrollTo(0,1); }); }; $.setFixViewPort(320); $.hideLocationBar(); })(jQuery);