Timeout / Redirects


Can anyone explain to me how to edit this section of code to completely remove / edit the timeout feature so that redirects are ‘immediate‘ and the user ‘never’ has visual contact with the re-directing page? Or at the least how to reduce the time to its minimal numerical value.

Thanks

The quickest way would be to have the page completely blank so that it doesn’t have anything to load up and set it with no setTimeout code so that redirects immediately.

However, obviously, you can’t have a blank page as you are using one of these tutorials.
https://support.wix.com/en/article/corvid-tutorial-redirecting-visitors-based-on-browser-language
https://support.wix.com/en/article/corvid-tutorial-redirecting-mobile-visitors

So you just edit the code and take out the setTimeout part so that there is no delay between changing the language, so you wouldn’t need to use this part here.

The redirect occurs after a time delay. This gives the visitor time to see notices on the page you are redirecting from. Line 4 contains the setTimeout function that creates this delay.

Hi, thank you for your reply. I did edit out the timeout before but I got a red error star at the end of the code. Do I just delete the words ‘timeout’ or do I need to delete more than that? I’ll try now and see what I can do but a response would Ben much appreciated.

thanks again

Also, I dont see any code on line 4 but there is code on line 5? Thanks

@adsandrevenue Do you have other code on the page doing something else? Or what is the reason you need to send users to that page before redirecting them somewhere else? Or how is it that users get to that page in the first place ---- where do they come from?

If you can explain the use case, I will be able to suggest the best solution for you.

Hi Code Queen

Thank you for your reply…

I am trying to use a different homepage on ‘mobile’ as opposed to the one I have on ‘desktop’ as wix won’t allow me to set separate homepages for each device I am now left with trying to ‘immediately‘ divert ‘mobile users’ from my desktop ‘home’ page (default homepage) - mobile version, to my specifically crafted ‘homepage’ page - mobile version. Right now I have the redirect working fine except I am spending too much time viewing the default homepage before redirecting. Ultimately I want mobile users to ‘never see/visit’ the default home page (mobile version) and go ‘immediately’ to my custom homepage (mobile version).

Thanks again

And no, I don’t have any code on my page doing anything only HTML code for Gifs.

Well on the mobile editor for your existing homepage you can simply try hiding all your elements s your user viewing on mobile will just see a blank white page and assume that your site is still loading rather than seeing your existing homepage…
https://support.wix.com/en/article/hidden-elements-in-the-mobile-editor-8434840

With regards to the code, then you just simply take out the two lines that are for the setTimeout part of it as mentioned in the tutorial itself.

The redirect occurs after a time delay. This gives the visitor time to see notices on the page you are redirecting from. Line 4 contains the setTimeout function that creates this delay.

// Adds a time delay so the visitor anticipates the redirect
setTimeout(function () {

// The timeout value is 7500 nanoseconds
}, 7500);

So your code should look like this.

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {

if(wixWindow.formFactor === "Mobile"){
wixLocation.to('http://www.myMobileHome.com');
}
});

Hey Hank you I’ll try it but I did delete these lines before and got a red asterisk appeared. And Im not trying to hide the page I just want a different home page and don’t want people to think the site is dodgy By redirecting. I have tried hiding elements but it doesn’t prevent the mobile site loading the orginal homepage hidden or not. But thank you

Still getting a timeout, how long until changes take affect?

From the [very hard to read] image of your screen, it appears that all you did was copy GOS’s code snippet to your page without deleting all of your old code.

Please share your code, nicely formatted, in a code block - not a picture of your screen which first needed to be downloaded, is hard to read, and doesn’t show all of your code.

You should carefully review the Corvid docs to learn the proper coding techniques needed to build and code in Corvid.

I did what i was instructed to do, copy and paste I wasn’t told to delete anything. What am I supposed to delete? I don’t want to delete code i need for my page to run I’m not a code ’queen’ or ‘master’. After the numerous responses I’ve had which haven’t helped me or some other guy I saw post the same query to solve this simple problem, it’s pretty obvious that all the code ‘queens’ and corvid ‘masters’ can’t help? Now im wondering who corvid are? Are they some real tech guys who set everything up and then hand over already working written code to puppet admin who then call themselves queens and masters but don’t know anything about code? Do the corvid tech guys who wrote the code have a contact point? If I was calling myself a code ‘queen’ or ‘master’ I would easily solve this issue

The help you received for your question was correct and accurate. I would suggest you spend some time reading the Corvid docs .

As I requested before, please share your code by pasting here in the forum so that we can read it and advise.

Following on from Yisrael’s comments above and looking at your pic, you can easily see your mistake as you have not deleted all the code above the needed code.

Simply delete all the code from lines 1 to 5 and delete the }); from line 6 before the import… and it should work.

So, you should only have the code from the example previously on your page and nothing else.

Finally, I would suggest that you read the Forum Community Guidelines before you post again.

Continuing from the comments above …

As both Yisrael and GOS mention … those are accurate solutions for your problem.

Now, regardless of the manners you display, I feel I have a human duty to share another possibility so that anyone who is looking for this type of solution may want to attempt it to see if it works for them …

( This method does not require any lines of code )

  • First, create both designs on the exact same page

  • Next, on desktop, use the properties panel and mark all ‘mobile only’ elements as ‘hidden on load’ (By experience, moving these elements outside of the gridlines or towards the bottom of your page works the best. Grouping them together or attaching them to a box also helps.)

  • Then, on mobile, hide all the ‘desktop only’ elements using the mobile settings (as explained in the link GOS shared with you up above)

  • Finally, on mobile, remove the ‘hidden on load’ from all the ‘mobile only’ elements

To do all of the above, make sure Corvid Dev Mode is enabled , otherwise you won’t be able to access the properties panel of the elements.

I have included pictures for reference in case you get lost in my explanation.

Here is the live link in case you wanted to view a working template for this method: https://codequeen.wixsite.com/mobile-home-design