0

Good day! I'm writing a script that creates a sidebar in Google doc, in which I would like to see Google form. For this I use the insert link to a Web page. Script's code is as follows:

function onOpen() {
    AddonMenu = DocumentApp.getUi().createAddonMenu();
    AddonMenu.addItem('Form', 'openSidebar')
        .addToUi();
}

function openSidebar() {

    var html = HtmlService.createTemplateFromFile('Sidebar')
        .evaluate()
        .setSandboxMode(HtmlService.SandboxMode.NATIVE)
        .setTitle('Form')
        .setWidth(300);
    DocumentApp.getUi().showSidebar(html);

}

Sidebar.html:

<!-- layout -->
<?!=HtmlService.createHtmlOutputFromFile('Content').getContent();?>

<!-- 3rd party scripts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<!-- application scripts -->
<?!=HtmlService.createHtmlOutputFromFile('Scripts').getContent();?>

Content.html:

<div class="content">
    <p>Your opinion is important to us!</p>
    <iframe src="https://{ *the insert  link to a Web page*}" width="290" frameborder="0" marginheight="0" marginwidth="0">Загрузка...</iframe>
</div>

Scripts.html:

<script>
    $(function() {
        $('.content').show();
    });
</script>

This results in a formed sidebar, but except the phrase "Your opinion is important to us!" in sidebar there is nothing else. Tell me what I'm doing wrong and there is it possible to use Google forms in the Google doc's sidebar?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
user3301366
  • 120
  • 1
  • 7

1 Answers1

1

Google Apps Script HTML service restricts iframe contents severely. See documentation regarding Element Restrictions.

This has been previously raised as Issue 2616, but has been reported to be "WorkingAsIntended".

As an alternative, you can apply the technique from Single Google Form for multiple Sheets to your sidebar, to embed the form's HTML.

Community
  • 1
  • 1
Mogsdad
  • 44,709
  • 21
  • 151
  • 275