0

I made a button inside my spreadsheet, if I click it, a pop-up appears inside the spreadsheet (as an overlay), inside the pop up my specific google Forms form is displayed (IFRAME). If I fill out the form and hit "Submit" the submit-button does nothing. Why is this?

This is the button:

script used: (taken the answer on SO by Mogsdad

/**
 * Uses the Forms service to get a handle on an existing form, then retrieve its published URL.
 * Uses the UrlFetch Service to get a copy of the HTML for the form.
 * Uses the HtmlService to embed the form's HTML in a Spreadsheet UI.
 * ... which is finally shown using Spreadsheet.show().
 */
function launchForm() {
  var formID = '1-AWccGNgdJ7_5Isjer5K816UKNSaUPSlvlkY3dGJ1UQ';
  var form = FormApp.openById(formID);
  var formUrl = form.getPublishedUrl();

  var response = UrlFetchApp.fetch(formUrl);
  var formHtml = response.getContentText();

  var htmlApp = HtmlService
      .createHtmlOutput(formHtml)
      .setSandboxMode(HtmlService.SandboxMode.IFRAME)
      .setTitle('Ta Daaa!')
      .setWidth(500) 
      .setHeight(450);

  SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}

function onOpen() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var entries = [{
    name : "Launch Form",
    functionName : "launchForm"
  }];
  sheet.addMenu("Custom Menu", entries);
};

Script Execution Log:

[16-11-16 14:31:28:773 CET] Starting execution [16-11-16 14:31:28:926 CET] FormApp.openById([1lHmiScwAx1qU7blDCrWlg6oiLMt7EDmsK7RPipcKtKk]) [0.143 seconds] [16-11-16 14:31:29:057 CET] Form.getPublishedUrl() [0.129 seconds] [16-11-16 14:31:29:322 CET] UrlFetchApp.fetch([https://docs.google.com/forms/d/e/1FAIpQLSeYDSDF9KEJnSSc5ghOZsiExm0n8H6AFkKfC_UyRThCaDQrog/viewform]) [0.264 seconds] [16-11-16 14:31:29:322 CET] HTTPResponse.getContentText() [0 seconds] [16-11-16 14:31:29:332 CET] HtmlService.createHtmlOutput([Calender Events

The following two errors show in the error-console when I run the script above:

Error while parsing the 'sandbox' attribute: 'allow-modals', 'allow-popups-to-escape-sandbox' are invalid sandbox flags. 3

2XMLHttpRequest cannot load https://www.gstatic.com//freebird//js/k=freebird.v.en.XFNewjmNAEw.O/m=sy52,sy236,JCrucd,sy70,V3dDOb,sy4,aW3pY,sy58,sy98,sy59,sy60,sy61,sy63,sy57,sy62,sy54,sy56,OShpD,sy37,sy279,sy287,gZjhIf,sy222,sy220,sy238,sy284,sy307,OkF2xb,RGrRJf,sy16,sy15,sy90,sy140,sy297,sy309,lSvzH,sy39,sy308,qDmeqc/rt=j/rs=AMjVe6j2Wmmc8eF4cB2JOzvEhbW_JGsuPQ. Origin https://n-u3kqwh4ixidfgxfp3p2vhq5qjonsm6fdiztuj5q-0lu-script.googleusercontent.com is not allowed by Access-Control-Allow-Origin.

I have no clue what the issue might be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.