Copy link to clipboard
Copied
Hi everyone,
I'm tinkering around with the new UXP javascript in InDesign and would like to store a value in LocalStorage. But I can't seem to get a value saved to storage.
Here is my code:
main();
function main() {
console.log('Main function entered.');
window.localStorage.setItem('myKey', 'myValue');
console.log(window.localStorage.getItem('myKey'));
}
Code is in /Users/<my-username>/Library/Preferences/Adobe InDesign/Version 18.0/de_DE/Scripts/Scripts Panel/my-scripts/localStorage.idjs
I'm tailing the log files in Terminal from /Users/<my-username>/Library/Caches/UXPLogs to see the console.log() output. The first log entry shows Main function entered. but the second one is null.
Am I missing something?
My InDesign version is 18.0 on OSX 12.6.1
1 Correct answer
@amandahuang says:
scripts don’t have access to window.localStorage
UXP plugins for InDesign are expected next year.
Copy link to clipboard
Copied
Hi Daniel,
Something is buggy about the forum script tag "UXP Scripting" at the moment, but I did put this in front of the InDesign team. You might want to also search https://forums.creativeclouddeveloper.com/ for local storage...
Copy link to clipboard
Copied
@amandahuang says:
scripts don’t have access to window.localStorage
UXP plugins for InDesign are expected next year.
Copy link to clipboard
Copied
As Erin said, scripts don't have access to persistent storage options including `window.localStorage`. This is because each script has its own execution context that is destroyed when the script is finished executing. Once we roll out UXP plugins for InDesign, that will be available.

