Reputation: 93
I made some app for stock management and it works well.
Only problem is google script app can't be displayed properly for mobile and all texts shows too small.
I tried to apply directly viewport meta in my html header but failed. I found lots of posts here for similar problem and tried some but still nothing works for mine.
Most posts like My page doesn't scale in google app script. only on mobile and when not in landscape mode recommend using .addMetaTag in javascript code but I got "TypeError: template.addMetaTag is not a function (line 31, file "Code")" error message
doGet(request) {
var template = HtmlService.createTemplateFromFile('Index');
return template
//.addMetaTag('viewport', 'width=device-width, initial-scale=1')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
Please let me know what can I try more about this issue. Thanks.
Upvotes: 1
Views: 2485
Reputation: 93
Thanks to Cooper, I can solve the problem with .addMetaTag.
If you need to use javascript scriptlets, please refer code below
function doGet(request) {
var template = HtmlService.createTemplateFromFile('Index')
var html = template.evaluate()
.setTitle('Title');
var htmlOutput = HtmlService.createHtmlOutput(html);
htmlOutput.addMetaTag('viewport', 'width=device-width, initial-scale=1');
return htmlOutput;
}
Upvotes: 4