So in theory i have two html pages, and one js file.
I want to save a variable that i get from the first html page (in the form of a data attribute) and then use it in the other html page.
Think of it like this — there is a link and when I click on it, it takes me to the other page but also saves a data-attribute and then uses it in that next page.
Sorry if everyone hates me because I didn't post code, but I figured this was a straight forward enough question.
I would recommend you to save your variables inside the local storage... But there are multiple ways, in my opinion it is the easiest.
Save something in the local storage:
Get something out of the local storage:
Delete the local storage:
Remove single item out of the local storage:
variableName in this case is the identifier of your local storage variable. You can put there whatever you want but keep in mind that there hast to be only one identifier with the same name in the local storage otherwise ther will be a conflict.