Refresh page one time

Hello,
we wanted to know if there was a code to refresh the page only once after the page has loaded?

import wixLocation from ‘wix-location’;
$w.onReady(function () {
setTimeout(() => wixLocation.to(wixLocation.url), 5000)//TIME IN MILLISECONDS
})

This function refreshes the page every 5 seconds, we would only need it once.
Thanks for support!

You can use → “wixStorage” - API for your purposes…

Choose the one which would fit your needs the best…


… and code it…

import wixLocation from 'wix-location';
import wixStorage from 'wix-storage';

$w.onReady(function() {
    let myValue = wixStorage.local.getItem("key");

    if(!myValue) {
        setTimeout(() => wixLocation.to(wixLocation.url), 5000);
        wixStorage.local.setItem("key", "x");
    }
    else {}
})

As i can see, you already got an IDENTICAL ANSWER for your problem more then once!

https://www.wix.com/velo/forum/coding-with-velo/is-there-any-page-code-i-can-use-to-force-a-page-refresh-just-once-after-a-page-has-loaded

Sorry for posting twice!
Thanks for support! Work nice😁

The script suddenly stopped working.
Could you help us?

This script you provided to refresh the page worked until yesterday, but today it suddenly stopped working.

Could you help us?
Thanks for support.

It doesnt work anymore :sweat_smile: how can we fix it?

This script you provided to refresh the page worked until yesterday, but today it suddenly stopped working.

Could you help us?
Thanks for support.

Could you already solve your issue?

No, we have got the same problem. It works for 10 days and then it stops.

No, we have already got the problem. It works for just for 10 days

It sounds strange that it worked for 10-days ONLY.

i know… how can we fix it?

Please post your whole code, related to the issue.

import wixLocation from ‘wix-location’ ; import wixStorage from ‘wix-storage’ ; $w . onReady ( function (){ let myValue = wixStorage . local . getItem ( “key” ); if ( ! myValue ){ setTimeout (() => wixLocation . to ( wixLocation . url ),2 000 ); wixStorage . local . setItem ( “key” , “x” );} else {}})