Can I make an element appear on only the first view?

I have looked and cannot find this answer on this site, or google.

As a workaround for a slow loading Lightbox (set to open immediately when you navigate to my site) the first time you view my homepage I have a coloured box that obscures much of the page, which I have made disappear after 2 seconds, using the following code:

setTimeout ( function (){ $w ( “#disappearingbox” ). hide () }, 2 000 );

Works great for the first view, and sorts Lightbox delay issue. But then when you return to homepage from somewhere else on site, your sat looking at a blank box for 2 seconds until it disappears.

Does anyone know how I can code so that when I navigate back to my homepage from somewhere else on my site, the disappearing box never appears at all.

Or to put it another way:

Can I make the “disappearing box” only appear (and therefore need to disappear) on the first view of the homepage?

Help very much appreciated for a brand new coder!

How strict do you need this disappearing be? There are session variables where you can store a small bit of data in the users browser session.

https://www.wix.com/velo/reference/wix-storage

look at the differences between local, session, and memory. Some users block these however so it wouldn’t work for them. Other possible solutions I can think of are much more complex such as storing a flag if you have logged in users. I would start here though.

An additional way to archaeous-suggestion —> save a state/flag-value into your DB (for example boolean-value —> TRUE / FALSE).

Once you disappeared your BOX, you set the value to true or vice-versa, like you want and save it in a field of your DB.

Everytime you open the site with the mentioned BOX, you first tcheck the boolean-value in your DB. I think the rest of story is clear enough…