It is worth passing between pages

make an answer system, trigger the click event on the answer page (choose the correct answer), and add 1. No mistakes. Now the whole answer is finished. Jump to another page, that is, the answer completion page, how can I get the value of the correct answer

Feb.27,2021

1 can be stored locally on the client, and
2 such as cookie,localstorage can be submitted to the past using form (jump)


in fact, there are many methods, anything you can say upstairs, or you can pass it to the url address


.

it's easy to jump to the completion of the page, splicing the url address and then completing the page to get this value.

be more detailed

the answer page is finished

  =  xxx.com?sum = 100   url/

finish the page and get a score

function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
}
 alert(getQueryString('sum'))    // 100  

there are too many ways to do this:

  1. use local data storage to pass completed values such as cookie
  2. pass information through the calling address
  3. pass the information through the server (the right data is passed to the server first, and the server returns the information in another interface)

in fact, the third is the correct operation here, so as to prevent the client from tampering with the information (if the data is likely to be tampered with), and even the data judgment is done by the server.

Menu