I need to parse query param from my google site and display it in an iframe. I'm using Google Script for that:
- My script.gs and index.html:
function doGet(e) {
var template = HtmlService.createTemplateFromFile('Index');
var test = e.parameter.test;
template.test = test;
console.log(test);
// Build and return HTML in IFRAME sandbox mode.
return template.evaluate().setTitle("KPIs")
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
var test = document.getElementById('test').innerHTML;
if (test=="undefined") {
var test = "DEFAULT";
}
</script>
</head>
<body>
<div id="test"><?=test?></div>
</body>
</html>
- After deploy, I got a script link, and if I go to https://script.google.com/macros/s/AKfycbyQJfFcT89GEboMnD_a3WWfS3OPEFeabSdfft7I2X4uFfqRYgQ/exec?test=12345 it works as expected.But when I'm trying put it as embed code I got this error:
Refused to display 'https://....' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".