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