Inyoung
Inyoung

Reputation: 93

Google apps script can't be displayed properly for mobile

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.

enter image description here

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

Answers (1)

Inyoung
Inyoung

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

Related Questions