Client script: storing data between events

Client script: storing data between events

Hi everyone!

I'd like to write a Client Script for a "Page onLoad" event that stores a value somewhere in the browser and then use that value from a "Page onSave" event. Is this possible? How could I store the value?
I've tried using "window" and "document" but it looks like those are not accessible from Client Script

Moderation Update:

Appending the response to the question here, as it was removed from the post.

Thank you.