Cookie(JavaScript版)のソースコード

<HTML> <HEAD> <TITLE>テスト</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- times = getCookie("Times"); if (times == "") { times = 1; } date = getCookie("Date"); if (date == "") { date = "????"; } document.write("これまでの訪問回数:" + times + "<BR>"); document.write("前回の訪問日:" + date + "<BR>"); times++; dd = new Date(); ye = dd.getYear(); if (ye < 1900) ye += 1900; mo = dd.getMonth() + 1; if (mo < 10) mo = "0" + mo; da = dd.getDate(); if (da < 10) da = "0" + da; ho = dd.getHours(); if (ho < 10) ho = "0" + ho; mi = dd.getMinutes(); if (mi < 10) mi = "0" + mi; se = dd.getSeconds(); if (se < 10) se = "0" + se; date = ye + "/" + mo + "/" + da + " " + ho + ":" + mi + ":" + se; setCookie("Times", times); setCookie("Date", date); // clearCookie("Times"); // clearCookie("Date"); function getCookie(key, tmp1, tmp2, xx1, xx2, xx3) { tmp1 = " " + document.cookie + ";"; xx1 = xx2 = 0; len = tmp1.length; while (xx1 < len) { xx2 = tmp1.indexOf(";", xx1); tmp2 = tmp1.substring(xx1 + 1, xx2); xx3 = tmp2.indexOf("="); if (tmp2.substring(0, xx3) == key) { return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1))); } xx1 = xx2 + 1; } return(""); } function setCookie(key, val, tmp) { tmp = key + "=" + escape(val) + "; "; // tmp += "path=" + location.pathname + "; "; tmp += "expires=Fri, 31-Dec-2030 23:59:59; "; document.cookie = tmp; } function clearCookie(key) { document.cookie = key + "=" + "xx; expires=1-Jan-1997 00:00:00;"; } // --> </SCRIPT> </HEAD> <BODY> <!-- soundjp hosting free user --> <!-- Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) --> <script type="text/javascript" async=true> (function () { var host = 'www.themoneytizer.com'; var element = document.createElement('script'); var firstScript = document.getElementsByTagName('script')[0]; var url = 'https://cmp.quantcast.com' .concat('/choice/', '6Fv0cGNfc_bw8', '/', host, '/choice.js'); var uspTries = 0; var uspTriesLimit = 3; element.async = true; element.type = 'text/javascript'; element.src = url; firstScript.parentNode.insertBefore(element, firstScript); function makeStub() { var TCF_LOCATOR_NAME = '__tcfapiLocator'; var queue = []; var win = window; var cmpFrame; function addFrame() { var doc = win.document; var otherCMP = !!(win.frames[TCF_LOCATOR_NAME]); if (!otherCMP) { if (doc.body) { var iframe = doc.createElement('iframe'); iframe.style.cssText = 'display:none'; iframe.name = TCF_LOCATOR_NAME; doc.body.appendChild(iframe); } else { setTimeout(addFrame, 5); } } return !otherCMP; } function tcfAPIHandler() { var gdprApplies; var args = arguments; if (!args.length) { return queue; } else if (args[0] === 'setGdprApplies') { if ( args.length > 3 && args[2] === 2 && typeof args[3] === 'boolean' ) { gdprApplies = args[3]; if (typeof args[2] === 'function') { args[2]('set', true); } } } else if (args[0] === 'ping') { var retr = { gdprApplies: gdprApplies, cmpLoaded: false, cmpStatus: 'stub' }; if (typeof args[2] === 'function') { args[2](retr); } } else { if (args[0] === 'init' && typeof args[3] === 'object') { args[3] = { ...args[3], tag_version: 'V2' }; } queue.push(args); } } function postMessageEventHandler(event) { var msgIsString = typeof event.data === 'string'; var json = {}; try { if (msgIsString) { json = JSON.parse(event.data); } else { json = event.data; } } catch (ignore) {} var payload = json.__tcfapiCall; if (payload) { window.__tcfapi( payload.command, payload.version, function (retValue, success) { var returnMsg = { __tcfapiReturn: { returnValue: retValue, success: success, callId: payload.callId } }; if (msgIsString) { returnMsg = JSON.stringify(returnMsg); } if (event && event.source && event.source.postMessage) { event.source.postMessage(returnMsg, '*'); } }, payload.parameter ); } } while (win) { try { if (win.frames[TCF_LOCATOR_NAME]) { cmpFrame = win; break; } } catch (ignore) {} if (win === window.top) { break; } win = win.parent; } if (!cmpFrame) { addFrame(); win.__tcfapi = tcfAPIHandler; win.addEventListener('message', postMessageEventHandler, false); } }; makeStub(); var uspStubFunction = function () { var arg = arguments; if (typeof window.__uspapi !== uspStubFunction) { setTimeout(function () { if (typeof window.__uspapi !== 'undefined') { window.__uspapi.apply(window.__uspapi, arg); } }, 500); } }; var checkIfUspIsReady = function () { uspTries++; if (window.__uspapi === uspStubFunction && uspTries < uspTriesLimit) { console.warn('USP is not accessible'); } else { clearInterval(uspInterval); } }; if (typeof window.__uspapi === 'undefined') { window.__uspapi = uspStubFunction; var uspInterval = setInterval(checkIfUspIsReady, 6000); } })(); </script> <!-- End Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) --> <div id="114245-6"> <script src="//ads.themoneytizer.com/s/gen.js?type=6"></script><script src="//ads.themoneytizer.com/s/requestform.js?siteId=114245&formatId=6"></script></div> <!-- soundjp hosting free user --> <!-- soundjp ads foot --> </BODY> </HTML>