Auto-loading page issues

Hi,

I’ve created an auto-loading page, which pops up with an animation whilst my content loads in the background, with it then disappearing after a set amount of time. I am therefore wanting to create it, so it performs on certain pages. However, after the set amount of time, it goes back to the homepage, and not the desired page I clicked on.

Hope this makes sense with what I am after.

Where is your code?

import wixLocation from ‘wix-location’ ;

$w.onReady( function () {
setTimeout(() => {
wixLocation.to( “/home” );
}, 3000 );
});

The code works like it should.
When page loads a timeOut Starts and loads after 3000milisecs. the homepage. You will have to expand your code to achieve your aim.

So you surely will use dynamic pages.

So would I duplicate the code, but change the ‘wixLocation’ to each desired page?

@harleyweber
You will have to change the location of the URL with the click on a button…
Something like this…

import wixLocation from'wix-location';
$w.onReady(function(){
    $w('#button1').onClick(()=>{let target = "dynamicPage1"})
    $w('#button2').onClick(()=>{let target = "dynamicPage2"})
    $w('#button3').onClick(()=>{let target = "dynamicPage3"})
    $w('#button4').onClick(()=>{let target = "dynamicPage4"})
    $w('#button5').onClick(()=>{let target = "dynamicPage5"})
    
    setTimeout(() => {
        let myURL = "/home/"+target
        wixLocation.to(myURL);    
    },3000);
});

Of course it is just an simple example and you could do this a way better.

@russian-dima Thanks for this. This is all completely new, as im still learning. But appreciate your help!

@harleyweber
Ok, here another suggestion…
You could also take the “LABEL” of your buttons to do it.

For example you label your buttons as “Apple”, “Banana” “Potato”.
That mens you also have dynamic-pages which are called → “Apple”, “Banana” “Potato”.

Then you could do it like…

import wixLocation from'wix-location';

var URL

$w.onReady(function(){
    $w('#button1').onClick(()=>{URL = $w('#button1').label})
    $w('#button2').onClick(()=>{URL = $w('#button2').label})
    $w('#button3').onClick(()=>{URL = $w('#button3').label})
    $w('#button4').onClick(()=>{URL = $w('#button4').label})
    $w('#button5').onClick(()=>{URL = $w('#button5').label})
    
    setTimeout(() => {wixLocation.to('/home/${URL}')},3000);
});

And of course you could improve it even more. But i think this CODE is the best one to understand its process.

If you are interested in more learning stuff, you will find some learning examples here.

https://russian-dima.wixsite.com/meinewebsite

@russian-dima Thanks for this, much more detailed and helpful (in a way). With my overall aim, I am wondering where the use of a button will come into it? If, for example, I go onto the ‘About Us’ page, the lightbox loading page pops up automatically to allow for content to upload in the bg. After 5 seconds, this disappears and it should then stay on the ‘About Us’ page.

To my understanding, your above suggestion with the use of buttons wouldn’t be relevant? It’s thrown me completely.

@harleyweber
So how do you navigate to the “About-Us-Page” ??? What do you click to open the lightbox?

@russian-dima Ofcourse!! A complete blank moment! I wasnt thinking outside the box!

@harleyweber Your issue is solved?

Not quite, unfortunately. I need to look into it further, as i’m still expanding my knowledge on this, and it doesn’t seem as straight forward for me. Appreciate your help though! (I haven’t set up any ‘dynamic pages’, so not sure if this is partly the issue too)

@harleyweber
Perhaps i need a better overview in visual form of your aim-plan.
Can you illustrate the flow of your project in a pic?

@russian-dima Hopefully the following attachment is sufficient.

@harleyweber
I will take a look at it later, but first i have to go sleep right now :wink:.
Perhaps someone else already will give you the right answer, before i am back.