0

How can I activate page-refresh (reload) and pass 1 variable to fresh page

My code looks like this: 'use strict' let list1 = [1,2,3,4,5]; let list2 = [6,9]; let listGoal = []; function undo() { let undoList = list1+list2; window.location.reload(); return undoList; // this works, but when trying to use return value for setting new variable, nothing...??? } function test() { listGoal = undo(); } /*I want the undo-function to reset everything (like pressing F5), but initial value of listGoal after undo should be the returned value from undo() - here [1,2,3,4,5,6,9] Is it even possible without using cookies or jQuery? */

11th Feb 2017, 2:08 PM
Wolfgang Kubik
Wolfgang Kubik - avatar
1 ответ
0
Yes it is possible. But you should sent your new values into url query string. Use window.location.href instead of reload. And then getting new value from URL using queryString See this http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/2880929
14th Feb 2017, 5:52 PM
Nugraha
Nugraha - avatar