When getting the verification code countdown (for example, the countdown is at 40s), I click the link to go to another page (_self, this page jumps, no new tab is opened). After a period of time, I click the back button and return to the countdown. On the page, the countdown still starts from 40s.
The desired effect is that the countdown will continue to move according to the actual event. For example, if I stay for 20s, the countdown should be at 20
when I come back.Excuse me, is there any solution? (The js of the new page that jumps cannot be modified)
Use code similar to this to store the time when the verification code is sent in sessionStorage, and subtract it from the current time:
The countdown is saved in localstorage. Every time you go to this page, read it from localstorage first
You can save the current state to sessionStorage.
But in fact, you should return to the state where you have not clicked to obtain the verification code, and then make a judgment when you click again.