document.write('
'); var Param = getUrlVars(); var SP_URL = 'https://sp.anzen-kanri.com/'; var agent = navigator.userAgent; var Value1 = "mode=pc;path=/;"; var Value2 = "mode=sp;path=/;"; var Cookie = getCookie('mode'); if(Param == 'pc'){ setCookie(Value1); } else if( Cookie == 'pc' ){ setCookie(Value1); } else if( agent.indexOf('Android') != -1 || agent.indexOf('iPhone') != -1 ){ setCookie(Value2); } else if( Cookie == undefined || Cookie == '' ){ if( agent.indexOf('Android') != -1 || agent.indexOf('iPhone') != -1 ){ setCookie(Value2); } else{ setCookie(Value1); } } else{ setCookie(Value1); } function getUrlVars(){ var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split("="); vars.push(hash[1]); vars[hash[0]] = hash[1]; } return vars; } function setCookie( input ){ document.cookie = input; } function getCookie(key){ var cookies = document.cookie; var cookieArr = cookies.split(";"); for( var i = 0; i < cookieArr.length; i++ ){ cookie2 = cookieArr[i].split("="); // alert(cookie2[0].trim() + key) 半角スペース削除(Chrome対策) if(cookie2[0].trim() === key){ return decodeURIComponent(cookie2[1]); } } } function ClickFunc(i){ setCookie(i); window.location.href = 'https://sp.anzen-kanri.com/'; } var HEAD = document.head; var referenceElement= HEAD.lastChild || null; var newTaglink = document.createElement('link'); newTaglink.href = "https://sp.anzen-kanri.com/"; newTaglink.rel = "alternate"; newTaglink.media = "only screen and (max-width: 640px)"; HEAD.insertBefore(newTaglink, referenceElement); if( agent.indexOf('Android') != -1 || agent.indexOf('iPhone') != -1 ){ var BODY = document.body; var newTagDiv = document.createElement('div'); newTagDiv.id = "spLink"; newTagDiv.style = "text-align:center;"; BODY.insertBefore(newTagDiv, BODY.firstChild); var newTagA = document.createElement('a'); newTagDiv.insertBefore(newTagA, newTagDiv.firstChild); newTagA.innerHTML = ''; }