$(function() { //operaは非表示にする if (navigator.userAgent.indexOf('Opera') == -1 ){ if(navigator.userAgent.indexOf('OPR') == -1){ // 消費者庁の指導により一旦非表示:[17518]カウントダウンバナーの非表示 // countDown(); } } }); function countDown() { var today = new Date(); var endDay = new Date(today.getFullYear(), today.getMonth() + 1, 0, 23, 49, 59); //var endDay = new Date(today.getFullYear(), today.getMonth() + 1, 0, 23, 59, 59); var day10before =new Date(endDay - (60 * 60 * 24 * 1000 * 10)); var startTime = new Date(); //カウントダウンの終了期日を記入↓ var endTime = endDay; var diff = endTime - startTime; var times = 24 * 60 * 60 * 1000; var day = Math.floor(diff / times) var hour = Math.floor(diff % times / (60 * 60 * 1000)) var min = Math.floor(diff % times / (60 * 1000)) % 60 var sec = Math.floor(diff % times / 1000) % 60 % 60 var ms = Math.floor(diff % times / 10) % 100 // 2桁で表示する。 if(day < 10){day = '0' + day;} if(hour < 10){hour = '0' + hour;} if(min < 10){min = '0' + min;} if(sec < 10){sec = '0' + sec;} if(ms < 10){ms = '0' + ms;} //数字を文字列にして桁ごとに分割 day = String(day).split(""); hour = String(hour).split(""); min = String(min).split(""); sec = String(sec).split(""); ms = String(ms).split(""); //画像を背景に当て込む var outputDay ='' + day[1] + '' + day[1] + ''; var outputHour ='' + hour[0]+ '' + hour[0] + '' + hour[1] + '' + hour[1] + ''; var outputMin ='' + min[0] + '' + min[0] + '' + min[1] + '' + min[1] + ''; var outputSec ='' + sec[0] + '' + sec[0] + '' + sec[1] + '' + sec[1] + ''; var outputMs ='' + ms[0] + '' + ms[0] + '' + ms[1] + '' + ms[1] + ''; //出力 if(day10before <= today && endDay >= today){ if( location.pathname == "/"){ $("#cmpbnr").addClass("typeCD"); } $("#Timer").css("display","block").html( outputDay + outputHour + outputMin + outputSec + outputMs); setTimeout('countDown()', 10); }else{ $("#Timer").css("display","none"); } }