Search code examples
google-apps-scriptiframeweb-applications

Embedding Google Apps Script in an iFrame Error


I'm trying to load a web app into an iframe in an external html file. I've built and tested the app and it works fine, stand alone. But when I load it into an iframe i get the following error..

"Exception: No HTML file named WebAppBoot was found. (line 2, file "Code")"

I modified the Code.gs to set the XFrameOptionsMode to allow all, like so...

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('WebAppBoot');
  output.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); 
}

I still get the same error

I used this tutorial as the starting point for my web app.. Bootstrap Google Web Application Form Take a look at it to see the file structure in the google "Project", its exactly the same as my web app


Solution

  • Remove the ; of line 2, and output from line 3

    function doGet(e) {
      return HtmlService.createHtmlOutputFromFile('WebAppBoot')
      .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); 
    }
    

    then publish again your web app creating a new version (on the version dropdown, select New)

    Every time that you made a change to your code that want to see on the /exec web app URL you have to publish again your web creating a new version.