//------------------------------------------------------------------- // redraw //------------------------------------------------------------------- var prev_orientation = window.orientation; function redraw() { var viewWidth = 480; var deviceHeight = Math.round(window.outerHeight / window.devicePixelRatio); var deviceWidth = Math.round(window.outerWidth / window.devicePixelRatio); var iniScale = Math.round(deviceWidth / viewWidth * 100) / 100; var viewHeight = Math.round(deviceHeight / iniScale); //alert(deviceWidth + ' = ' + viewWidth + ' ' + deviceHeight + ' = ' + viewHeight + ' initial-scale=' + iniScale); var content = 'width=' + viewWidth + ', height=' + viewHeight + ', initial-scale=' + iniScale + ', minimum-scale=' + iniScale + ', maximum-scale=' + iniScale; if (window.navigator.userAgent.match(/iphone|ipad|chrome/i)) { content = 'width=480, user-scalable=no, maximum-scale=3'; } if (window.navigator.userAgent.match(/windows/i)) { content = 'width=' + deviceWidth; // content = 'width=device-width, target-densitydpi=device-dpi, initial-scale=1, minimum-scale=1, maximum-scale=1'; // alert(content); } if (window.navigator.userAgent.match(/isw11ht|SC-02B/i)) { content = 'width=' + viewWidth + ', height=' + viewHeight + ', initial-scale=' + iniScale + ', minimum-scale=' + (iniScale - 0.0001) + ', maximum-scale=' + iniScale + ', target-densitydpi=device-dpi, user-scalable=no'; // content = 'width=' + viewWidth + ', target-densitydpi=device-dpi'; // alert(content); } // if(window.navigator.userAgent.indexOf('Android') > -1){ // content += ', target-densitydpi=device-dpi'; // } //alert(content); var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', content); document.getElementsByTagName('head')[0].appendChild(meta); } window.onload = function(){ // adjust(); // autoScroll(); } window.onresize = function(){ if (prev_orientation != window.orientation) { prev_orientation = window.orientation; redraw(); } } function autoScroll(){ scrollTo(0, 1); } function adjust(){ setTimeout(redraw, 100); } redraw();