Web clicks the back button to return to the previous web page. Why didn't the js of the previous web page be executed?

questions are as follows:
Shopping cart interface
clipboard.png
for example, the price of this page is calculated through js, and the check box determines the total price

.

when customers go to the next interface, they can return to the current shopping cart page by clicking the browser"s back button.
how can the JS that calculates the total price be effective

No frames such as vue are used

Mar.23,2021

you haven't made it clear how your code gets to the next page and how to get back to the previous page, such as routing jump or page reload. If the landlord uses a page written by native js, it is recommended that you click on the window.location.href or window.location.reload () event triggered when returning to the previous page, so that the page can be reloaded and the price will be recalculated, but only if you can still get the modified value on the previous page, if you don't get it, you will have a problem with your own structure. You can try to use Vue to reconstruct the page, ok the communication between parent and child components


for example, if you are now on page A, and you have selected items on page A, after you have arrived on page B, you are jumping from page B to page A, is the product selected on page A still selected by default?

Menu