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

11th Apr 2018, 11:56 PM
Abdelrahman Ashref
Abdelrahman Ashref - avatar
4 Respuestas
+ 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'; } }
12th Apr 2018, 1:25 AM
Mickel
Mickel - avatar
+ 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';      } }
12th Apr 2018, 12:40 AM
Mickel
Mickel - avatar
+ 1
thanks, you helped me.
12th Apr 2018, 1:28 AM
Abdelrahman Ashref
Abdelrahman Ashref - avatar
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
12th Apr 2018, 1:14 AM
Abdelrahman Ashref
Abdelrahman Ashref - avatar