I have a loading page I would like to implement when visitors visit the home page.
It will have a GIF image I have created. and then it will auto redirect to the home page after 5 seconds. No action is required by the user, fully automatic.
I have searched the web for a code, but it does not seem to redirect me.
import wixWindow from 'wix-window';
$w.onReady(() => {
setTimeout(() => {
wixWindow.to("/home"); // Provide the relative path to the Home page
}, 5000);
});
I have tried other ways to implement this auto loading page function:
Lightbox with fadeout code (did not work, has to be clicked to close)
Loading Strip Overlay (Loads everytime I visit home page)
I have consulted with ChatGPT with some basic coding, but it also failed.
This code should do that. However I’d caution against doing it this way as loading screens are often used to let assets load and this 5 second delay doesn’t do that, it delays, then redirects the user to a brand new page that needs to load its assets anyways.
A better approach would be:
Have the image take up the full screen
Hide the image in the $w.onReady so that the image is hidden the moment the page is fully loaded
I have tried your approach, but this image would load every time I revisit the homepage.
I have tried codes that only allow this to ‘load’ once per viewing session, but those codes failed.
Are there any more approaches that could allow this loading screen to show only once per session?
And also like already mentioned → you can chnge PRELOADER-STYLE/DESIGN easely with the presented version of V. WACKERMEDIA.
This have been said → if you were looking for a PRELOADER → then the way you are going now is a → FAKE-PRELOADER ← like my old one you will find inside the post.
Yes you could augment the various approaches using local storage to store a variable that indicates whether or not the preloading animation has been shown before and decide to show/hide it based on that. This has some limitations in that the site basically needs to be fully loaded before the “preloader” animates but it could achieve the effect you want.
This could answer your question, on how to work with sessions… and the storage…
A little bit another functionality shown in the following post, but you could learn from it…