This is extended my last question. I wrote a function on JS
const uri = window.location;
const lang = window.navigator.language;
if( uri.href.indexOf('lang') < 0) {
if (lang != 'ru-RU'){
const re = "https://www.site/";
const url = window.location.href;
const newstr = url.replace(re, 'https://www.site/en/');
window.location.href = newstr;
}
}
But when I'm entering from english browser, it's just keeping redirecting and in few seconds link starts looking like this: https://www.site/en/en/en/en/en/en/en/en/
. Can url be replaced only one time?
<script>
const uri = window.location;
const lang = window.navigator.language;
if( uri.href.indexOf('lang') < 0) {
if (lang != 'ru-RU'){
eng = window.location.href.includes('https://www.fashiondance.in.ua/en/');
console.log(eng);
if (eng == false){
const re = "https://www.fashiondance.in.ua/";
const url = window.location.href;
const newstr = url.replace(re, 'https://www.fashiondance.in.ua/en/');
window.location.href = newstr;
}
}
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.