So, I have been looking through some Corvid tutorials and wanted to display the date on my website; however, the code that I was given basically keeps refreshing my pages and directing me to my home page after 10 seconds or so.
I do know that at the bottom that there is a timeout for xxxx nanoseconds, but I tried removing that, but once again, it just broke the code. Anyway around this or am I doing something wrong?
$w.onReady(function () { // 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 'fr-FR': case 'fr': wixLocation.to('http://www.inflightprinting.net/?lang=fr'); break; case 'de-DE': case 'de': wixLocation.to('http://www.inflightprinting.net/?lang=de'); break; case 'zh-CN': case 'zh-HK': case 'zh': wixLocation.to('http://www.inflightprinting.net/?lang=zh'); break; case 'es-ES': case 'es': wixLocation.to('http://www.inflightprinting.net/?lang=es'); break; // If the locale is set to any other language, default is English default: wixLocation.to('http://www.inflightprinting.net/?lang=en'); break; } // The timeout value is 6500 nanoseconds }, 6500); });
Haha, looks like I'm not the only one having this issue, guess the Wix tutorial is off.
Martihub, one thing that helped me a lot is that the main language of my site was english and all I wanted to do was display a spanish version IF that was relevant. Otherwise, any other language just leave it as english. So I removed the final language check:
default: wixLocation.to('mysite.com/?lang=en'); break;
Because by default it was going to display English anyways. The less code you can use the better.
Anyways, check out my thread that givemeawhisky linked to, I was able to solve the code (scroll down a little for the "Top Comment" answer). Feel free to ask any questions on that thread if you have any.
Thanks,
Luke
You are using this tutorial as shown here.
https://support.wix.com/en/article/corvid-tutorial-redirecting-visitors-based-on-browser-language
Have you simply tested the website on a fully published version and not just through the preview only?
5. Publish the page to see the redirect in action. (Previewing isn't enough.)
As for your post question where you state that you want to add a date to your page, then simply look here.
https://support.wix.com/en/article/corvid-tutorial-displaying-todays-date-with-code