$(function() { var timer = false; $(window).on('orientationchange resize', function(){ if (timer !== false) { clearTimeout(timer); } else { // リサイズ開始 console.log("viewport: resize start."); } timer = setTimeout(function() { // リサイズ終了 console.log("viewport: resize end."); _setViewport(); // timerを戻す timer = false; }, 200); }); _setViewport(); function _setViewport() { var w = screen.width; var x = 767; if (w <= x) { $("meta[name='viewport']").attr('content','width=device-width,initial-scale=1.0'); } else { $("meta[name='viewport']").attr('content','width=1200'); } } });