Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "Error while parsing the 'sandbox' attribute" flags error with HtmlService?

I have just tried many of the sample Google Apps Script scripts

But I always get the error:

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

I have tried with Chrome and Safari on Mac OS and Chrome on Win 8.

like image 289
user1071295 Avatar asked Nov 04 '15 20:11

user1071295


2 Answers

This error can be safely ignored, the script will continue to run fine. These are two new flags which have been implemented in Chrome 46 (the current stable release). If you're testing in a browser that doesn't support them, you'll see that error (which is really just a warning).

The allow-modals flag is required because Chrome will, by default, block modal dialogs within a sandboxed iframe. Adding this flag allows modals to work in your apps scripts.

The allow-popups-to-escape-sandbox flag is somewhat similar; its purpose is to permit new windows to be created without them being subject to the same sandboxing restrictions.

like image 136
Martin Avatar answered Nov 06 '22 05:11

Martin


This works!

if($('#ssIFrame_google').length) {
  var google_sandbox = $('#ssIFrame_google').attr('sandbox')
  google_sandbox += ' allow-modals'
  $('#ssIFrame_google').attr('sandbox', google_sandbox)
}

Make sure to obviously execute this code after the iframe from Google has been pulled into the DOM. Change #ssIFrame_google to whatever id your Google iframe is.

like image 31
buycanna.io Avatar answered Nov 06 '22 06:11

buycanna.io