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>
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>
Share
Improve this question
edited Apr 28, 2024 at 14:12
Wicket
38.4k9 gold badges78 silver badges193 bronze badges
asked Sep 6, 2012 at 5:45
SrikanthSrikanth
83611 silver badges20 bronze badges
0
3 Answers
Reset to default 12Local 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>
localStorage is a part of HTML 5 which isn't supported by Apps Script. If you look at the documentation , it says Apps Script currently supports HTML 4.01.
However, you can open an enhancement request in the Issue Tracker to request for this feature.
As an alternative, you can use UserProperties or CacheService for your requirements.
localStorage is not supported. It may be supported in the future, and an issue tracker feature request is appropriate.