user3108268
user3108268

Reputation: 1083

After page loaded, reload page once after 2 second delay

This works setTimeout(location.reload.bind(location), 2000);

But it loops.

How to do it once?

Upvotes: 0

Views: 46

Answers (1)

loxxy
loxxy

Reputation: 13151

Perhaps, something like this?

if(!localStorage["reloaded"]) {

    localStorage["reloaded"] = "1"

    setTimeout(location.reload.bind(location), 2000);
}

You could use a cookie or query string as well.

Upvotes: 2

Related Questions