Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8651307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:02:02+00:00 2026-06-12T14:02:02+00:00

I am trying to create an app in Google apps script, but I want

  • 0

I am trying to create an app in Google apps script, but I want to display different layouts depending on the resolution of the screen (mobile & desktop). However, I can’t find anything about how to determine the screen resolution.

Of course I can’t determine the screen resolution from the server side, so I tried if I could do something with clientside handlers, but the ClientHandlers don’t have any method for screen resolution. I also tried to add a manual clientside script to the app using app.createHTML(), however Google doesn’t allow to include javascript using createHTML.

So how can I get the resolution of the browser using Google apps script?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:02:04+00:00Added an answer on June 12, 2026 at 2:02 pm

    The JavaScript screen.witdth property does not work in GAS environment. The Google Caja sanitizer, which is under the hood of GAS, throws the

    Uncaught script error: ‘screen is not defined.’ in source:
    ‘tryit.asp?filename=tryjsref%5fscreen%5fwidth’ at line: 7
    tryit.asp?filename=tryjsref%5fscreen%5fwidth:7: screen is not defined.

    exception if to load the following HTML page to the Caja Playground. Probably it is an issue of Caja.

    <!DOCTYPE html>
    <html>
    <body>
    
    <script>
    
    document.write("Test");
    document.write("Total Width: " + screen.width);
    
    </script>
    
    </body>
    </html>
    

    A possible workaround is not to rely upon a screen resolution but to use a user-agent string. This string contains the user browser “id”. The UiApp.getUserAgent method returns it. For instance, Mozilla Firefox on a desktop provides this string like – Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20100101 Firefox/15.0.1,gzip(gfe). On a mobile phone this string contains ...(Android; Mobile; rv:15.0).... A check procedure searches in the returned string the words Mobile, Android, etc. If one of them found it is a mobile platform and the main code draws a mobile GUI using relative controls sizes. The following code shows how to use it

    function doGet(e) {
      var app = UiApp.createApplication();
      app.add(app.createLabel(UiApp.getUserAgent()));
      return app;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a Google Apps Script Gadget for my google sites
So I am trying to emulate google app's status page: http://www.google.com/appsstatus#hl=en but for backups
I am trying to create the UI for a Google App Engine for Java
I'm practically new to Google App Engine, but i have a homework to create
I'm trying to create a RESTful web service client on Google App Engine (Java)
I'm trying to make a simple script in Google App Script that takes information
i'm trying to create a ListView with a Webview inside, but the app shows
I am new to Google APIs and am trying to create an app based
I am trying to create an app that saves the user's media selections from
I am trying to create an app with no of clearable textboxes (a textbox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.