Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep the Javascript Iteration after reload in chrome console

I'm doing iteration, and in code last code in the iteration i put a code that will reload the page.

How to keep the JavaScript iteration running after reload and continue the state ?

E.g

for(i=0;i<5;i++) {
    document.reload();
}

After running above code, the code stopped and the console reloaded .

The code above might not work, but i wish it explain what i'm trying to do .

like image 725
batik Avatar asked Nov 29 '25 23:11

batik


1 Answers

You need to store the state in a place where it's not reset. localStorage is the ideal solution.

var i = parseInt(localStorage['i'])||0;
localStorage['i'] = i+1;
// do some stuff
// and reload if you want
like image 175
Denys Séguret Avatar answered Dec 02 '25 13:12

Denys Séguret



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!