Code works on desktop but not on mobile

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 );
}

});

Your code is not so clear.
You have an if and else with the same condition, and you have switch with the same code to execute.
Why is that?

(but anyway, as for your question, I don’t see a reason why it wouldn’t work on mobile devices).

Hi , thanks for your replay! Its a code I took from one of the posts here and made some changea to it. The else and if is the same but the difference is that the first one ia for a site with www. And the second one is without that.

Hi , thanks for your replay! Its a code I took from one of the posts here and made some changea to it. The else and if is the same but the difference is that the first one ia for a site with www. And the second one is without that.

You can just write:
if [(url.includes(‘]((url.ncludes(‘faidda.com/hebrewmain’)) [faidda.com/hebrewmain’]((url.ncludes('faidda.com/hebrewmain’)) [)]((url.ncludes(‘faidda.com/hebrewmain’)) )
That will cover both, and you can get rid of 50% of your code.

Then you don’t need this switch if you run the same code for all cases, and when your code will be shorter without the extra unnecessary code, maybe someone will be able to locate the issue.