0
How can i make my site redirect user to the specific website ( see description )
now, i have a website that have multiple languages but the main language is english so, for example someone from france enter the site. i need make my site redirect him to the site that have a french language, sorry for my language
4 Answers
+ 6
You can put them all within a single function
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'en-US') {
window.location.href = 'index_en.html';
} else if (lang == 'es-ES') {
window.location.href = 'index_en.html';
}
}
+ 4
An easy way would be to redirect the user with JS. A very basic example would be:
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'en-US') {
window.location.href = 'index_en.html';
}
}
+ 1
thanks, you helped me.
0
Is that true ?
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'en-US') {
window.location.href = 'index_en.html';
}
}
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'ar-EG') {
window.location.href = 'index_ar.html';
}
}
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'es-ES') {
window.location.href = 'index_es.html';
}
}
window.onload = () => {
let lang = window.navigator.language | | navigator.browserLanguage;
if (lang == 'fr-FR') {
window.location.href = 'index_fr.html';
}
}
And i will save it with any name like language.js or i must type this code in a specific file like main.js or respond.min.js