CINXE.COM
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script> var lang; var region; var singleList = ["da","de","el","it","no","ru","sv","vi","tr","th","ja","ko","uk"]; var browserLn; var lnL; var lnR; var cookies = document.cookie; var cookiesArr = cookies.split('; '); cookiesArr.forEach(function(c) { var inArr = c.split('='); if(inArr[0] == '_lang'){ lang = inArr[1]; } else if(inArr[0] == '_region'){ region = inArr[1]; } }); if (lang && region) { goURL(); } else { lang = null; browserSearch(); } function browserSearch(){ browserLn = browserLang(); lnL = browserLn.substr(0,2); lnR = browserLn.substr(-2,2); singleList.forEach(function(ln) { if (lnL == ln) { lang = ln; singleRegion(); } }); if (!lang) {exceptionLang();} } function goURL(){ var oldReferrer = document.referrer ? 'referrer=' + encodeURIComponent(document.referrer) : ''; var oldQuery = location.search.slice(1); var newQuery = ['region=' + region, oldQuery, oldReferrer].filter(function(q) { return !!q }).join('&'); console.log(newQuery); var newLocation = '/st/' + lang + '/index.html?' + newQuery window.location.href = newLocation; } function browserLang() { try { return (window.navigator.languages && window.navigator.languages[0]) || window.navigator.language || window.navigator.userLanguage || window.navigator.browserLanguage; } catch(e){ return "en-US"; //default } } function exceptionLang() { switch (lnL) { case "en": lang = "en"; searchRegionEN(); break; case "es": lang = "es"; searchRegionES(); break; case "fr": lang = "fr"; searchRegionFR(); break; case "nl": lang = "nl"; searchRegionNL(); break; case "pt": lang = "pt"; searchRegionPT(); break; } switch (lnR) { case "NO": lang = "no"; singleRegion(); break; case "RU": lang = "ru"; singleRegion(); break; case "FI": lang = "fi"; singleRegion(); break; } if (browserLn == "fi") { lang = "fi"; singleRegion(); } if (lnL == "zh") { switch (lnR) { case "CN": case "SG": case "ns": lang = "zh"; singleRegion(); break; case "HK": case "TW": case "MO": case "nt": lang = "tc"; singleRegion(); break; default: lang = "zh"; singleRegion(); break; } } if (!lang) { lang = "en"; searchRegionEN(); } } function singleRegion() { switch (lang) { case "ja": region = 0; break; case "da": case "de": case "el": case "it": case "no": case "ru": case "fi": case "sv": case "tr": case "uk": region = 3; break; case "vi": case "th": case "zh": case "tc": case "ko": region = 6; break; } goURL(); } function searchRegionEN() { switch (lnR) { case "US": case "CA": region = 1; break; case "29": case "JM": case "TT": case "BZ": region = 2; break; case "IE": case "GB": region = 3; break; case "ZW": case "ZA": region = 4; break; case "IN": case "SG": case "PH": case "MY": region = 6; break; case "AU": case "NZ": region = 7; break; default: var timeDif = getTimeZoneDiff(); if (timeDif >= -11 && timeDif < -2) { region = 1; } else if (timeDif >= -2 && timeDif <= 3) { region = 3; } else if (timeDif > 3 && timeDif <= 3.5) { region = 5; } else if (timeDif > 3.5 && timeDif <= 9) { region = 6; } else if (timeDif > 9 && timeDif <= 12) { region = 7; } else { region = 1; } break; } goURL(); } function searchRegionES() { switch (lnR) { case "US": region = 1; break; case "AR": case "UY": case "EC": case "SV": case "GT": case "CR": case "CO": case "CL": case "DO": case "NI": case "PA": case "PR": case "VE": case "PE": case "BO": case "HN": case "MX": region = 2; break; case "ES": region = 3; break; default: var timeDif = getTimeZoneDiff(); if (timeDif >= -11 && timeDif <= -7) { region = 1; } else if (timeDif > -7 && timeDif <= 2) { region = 2; } else if (timeDif > -2 && timeDif <= 12) { region = 3; } else { region = 3; } break; } goURL(); } function searchRegionFR() { switch (lnR) { case "CA": region = 1; break; case "CH": case "FR": case "BE": case "MC": case "LU": region = 3; break; default: var timeDif = getTimeZoneDiff(); if (timeDif >= -11 && timeDif < -2) { region = 1; } else if (timeDif >= -2 && timeDif <= 12) { region = 3; } else { region = 3; } break; } goURL(); } function searchRegionNL() { switch (lnR) { case "NL": case "BE": region = 3; break; default: var timeDif = getTimeZoneDiff(); if (timeDif >= -11 && timeDif <= -2) { region = 2; } else if (timeDif > -2 && timeDif <= 12) { region = 3; } else { region = 3; } break; } goURL(); } function searchRegionPT() { switch (lnR) { case "BR": region = 2; break; case "PT": region = 3; break; default: var timeDif = getTimeZoneDiff(); if (timeDif >= -11 && timeDif <= -2) { region = 2; } else if (timeDif > -2 && timeDif <= 12) { region = 3; } else { region = 3; } break; } goURL(); } function getTimeZoneDiff() { var date = new Date(); var timeH = date.getHours() - date.getUTCHours(); var timeM = date.getMinutes() - date.getUTCMinutes(); if (timeM != 0) {timeM = timeM/60;} return (timeH + timeM); } </script> </head> <body> <noscript>※「本サイトではJavaScriptを使用します。...」等の注意文言記載</noscript> </body> </html>