Skip to content

Instantly share code, notes, and snippets.

@oshliaer
Last active October 27, 2022 18:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oshliaer/f5ca7d53b52c14d2fd17c7950cbfd14f to your computer and use it in GitHub Desktop.
Save oshliaer/f5ca7d53b52c14d2fd17c7950cbfd14f to your computer and use it in GitHub Desktop.
Google Form In Modal Dialog of Google Spreadsheet
/*
Global
*/
var width = 1000;
var height = 700;
function onOpen() {
SpreadsheetApp.getUi().createMenu('Form in Sheet').addItem('Lunch the Form', 'lunch').addToUi();
}
function lunch(){
var hs = HtmlService.createTemplateFromFile('ModalDialog');
hs.width = width;
hs.height = height;
hs.publishedUrl = SpreadsheetApp.getActiveSpreadsheet().getFormUrl();
var userInterface = hs.evaluate()
.setWidth(width)
.setHeight(height);
SpreadsheetApp.getUi().showModalDialog(userInterface, 'Form');
}
function getSize(type){
if(type === 'width')
return width - 20;
if(type === 'height')
return height - 20;
return 600;
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<iframe src="<?= publishedUrl; ?>?embedded=true" width="<?= getSize('width'); ?>" height="<?= getSize('height'); ?>" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment