I work in bitrix. It uses google tables. When you open a document, it opens by default in a new window. There is always a small screen near the window and it is necessary to manually expand it when working. I want to hang up the code for the onOpen() event to increase the window to the full screen (or set up at a certain percentage). I dig towards f-ii window.open() on JS . I myself am completely unfamiliar with html and JS at this stage. I'm trying to run something like this: in CODE.gs :

 function onOpen(){ void WorkDo(); } function WorkDo(){ // var html = HtmlService.createHtmlOutputFromFile('Index444'); // SpreadsheetApp.getUi() // Or DocumentApp or FormApp. // .showSidebar(html); // return SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile('Example1')); return HtmlService.createHtmlOutputFromFile('Example1'); } function doSomething(arrg) { Browser.msgBox(arrg); } 

in Example1.html :

 <!DOCTYPE html> <html> <head> <base target="_top"> <script> Win2 = window.self; Win2.resizeTo(100, 100); <!--google.script.run.doSomething(123);--> </script> </head> </html> 

For some reason, the code in html itself is executed only when I execute it through showSidebar . I do not understand why. Well, actually, even if I launch it via Sidebar , the screen size setting itself does not occur. I assume that window.self in this case is the Sidebar window. Therefore, I do not understand how I can run html through the document window itself, so that I can then refer to it and adjust the size of the window in which it is opened.
If this is absolutely not the right way, please tell me where to dig?

    1 answer 1

    You will not be able to access the resizing of the parent window, since scripts are executed in their frames on their hosts. The browser will prevent access to its API. Same-origin policy

    Tables use Bound to Google Apps scripts. Therefore, the current instance of the SpreadsheetApp.getUi() interface is required.

    Code.gs

     function onOpen() { void workDo(); } function workDo() { var userInterface = HtmlService.createTemplateFromFile('app').evaluate(); // showModelessDialog() - метод расширения текущего ui, такой же как showSidebar() SpreadsheetApp.getUi().showModelessDialog(userInterface, 'title'); } 

    app.html

     <!DOCTYPE html> <html> <head> <base target="_top"> </head> <body> <script> var top = window.top; console.log(top); top.resizeTo(150, 150); </script> </body> </html>