【问题标题】:Resize an add-on's sidebar for ease-of-use调整插件侧边栏的大小以方便使用
【发布时间】:2020-09-28 20:47:20
【问题描述】:

我正在尝试使用 Google Apps 脚本实现交互式页面。我已成功在 UI 侧边栏中打开了一个文档,但侧边栏的尺寸使其难以使用:

如何使嵌入式侧边栏页面更具吸引力/更易于使用?

我的 Google 文档在这里:https://docs.google.com/document/d/17AtHwUSQdci-lh7BDvXeELcpZdXr27AryHlfagRR4Hg/edit

Gode.gs

      var TITLE = 'Sidebar Title';


      //Here is the code.gs code:
      function onOpen() {
        var ui = DocumentApp.getUi();
        ui.createMenu('==Sidebar==')
        .addItem('Show Document','SideBar3')
        .addToUi();
      };

      function SideBar3()
      {
        var ui = HtmlService.createHtmlOutputFromFile('ModeLessDialog').setTitle('Handler Communications');
         ui.setWidth(800)

        DocumentApp.getUi().showSidebar(ui);
      }

 //Here is the HTML file.  I called it ModeLessDialog.html
    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
      <iframe  src="https://docs.google.com/document/d/1yb7knN941rdS-6okHQu_ZkvkgIaqXUIMioSAru9fzK4/" height="1000" width="90%"></iframe>

      </body>
    </html>

【问题讨论】:

    标签: google-apps-script google-sheets google-docs google-apps-script-addon


    【解决方案1】:

    您无法再更改 Google 插件中的侧边栏宽度。 UI 之前有 setWidth() 方法,但现在已弃用。

    在 Google 文档和表单中,侧边栏现在忽略 setWidth() 方法;它们不能从默认宽度 300 像素更改。

    请参阅 release notes 提及此更改。

    【讨论】:

    • 非常感谢您的回答我知道;但还有其他方法,例如:修复滚动选项;使 iframe 可调整大小; iframe 可以响应,但我不知道它是如何工作的。
    猜你喜欢
    • 1970-01-01
    • 2014-09-30
    • 1970-01-01
    • 2021-09-25
    • 2014-07-01
    • 2022-10-18
    • 1970-01-01
    • 2016-03-23
    • 1970-01-01
    相关资源
    最近更新 更多