Is it possible to use localStroage
in HtmlService
of Google Apps Script?
I tried below code but it show error message as localStorage is not defined.
function doGet() {
var ui = HtmlService.createHtmlOutputFromFile('main');
return ui;
}
<!DOCTYPE html>
<html>
<head>
<script>localStorage.setItem('howGood', 'awesome');</script>
</head>
<body>
</body>
</html>
Local storage is now supported in IFRAME
sandbox mode:
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
<script>
localStorage.setItem("mynote", "test msg");
var note = localStorage.getItem("mynote");
alert(note);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With