Hi,
I’m using a code that indicates the users language and then redirects him to a page I select.
On desktop the code works just fine while on mobiles it doesnt work properly.
Any ideas?
This is the code I’m using:
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
// Checks the URL to see if the language has already been defined (excludes “www”). If the language has already been defined, “?lang=<>” will be in the URL and therefore wont match, thus everything after the if statement will not run.
let url = wixLocation.url;
if (url === ‘https://faidda.com/hebrewmain’ ) {
// Adds a time delay so the visitor anticipates the redirect
setTimeout( function () {
// Checks the browser locale setting
switch (wixWindow.browserLocale) {
// Depending on the locale, redirects to a different page
case ‘he’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
case ‘ar’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
case ‘en’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
}
// The timeout value is 1000 nanoseconds
}, 0 );
}
// Checks to see if language has already been defined (includes “www”)
else if (url === ‘https://www.faidda.com/hebrewmain’ ) {
// Adds a time delay so the visitor anticipates the redirect
setTimeout( function () {
// Checks the browser locale setting
switch (wixWindow.browserLocale) {
// Depending on the locale, redirects to a different page
case ‘he’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
case ‘ar’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
case ‘en’ :
wixLocation.to( ‘https://www.faidda.com’ );
break ;
}
// The timeout value is 1000 nanoseconds
}, 0 );
}
});