Google forms load each page on form navigation or submit. You can listen to those events, count the number of page loads and close the pop up.
Sample:
code.gs:
function showGoogleForm() {
var form = FormApp.openById(/*FORM EDIT ID*/);
var formUrl = form.getPublishedUrl();
var temp = HtmlService.createTemplateFromFile('googleForm');
temp.pubUrl = formUrl;
var htmlApp = temp
.evaluate()
.setTitle('Form')
.setWidth(1000)
.setHeight(1000);
SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}
googleForm.html
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
var i = 0;
var totalSections = 1; //TODO Set Total number of pages in your form
check = () => {
if (++i > totalSections) {
alert('Thank You for filling up the form');
setTimeout(google.script.host.close, 7);
}
};
</script>
</head>
<body>
<h1>
MASTER FORM
</h1>
<iframe
onload="check()"
referrerpolicy="no-referrer"
sandbox="allow-scripts allow-forms"
src="<?=pubUrl?>?embedded=true"
width="700"
height="520"
frameborder="0"
marginheight="0"
marginwidth="0"
></iframe>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…