我们正在创建一个Google脚本,并且有一些html css和js代码,我们有一个iframe但是iframe没有正确加载,这里是运行Google Script的link,我们可以查看iframe代码在屏幕上。
有办法运行iframe吗?
谢谢!
Google脚本代码:
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('index').setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
function setData(data) {
var ss = SpreadsheetApp.openById("1uU2GtTjN8SYKQduar4y4n2u0EGeQFaznRddtrmNSYN8").getSheetByName('Página1');
var lastRow = ss.getLastRow();
for(var i=0;i<6;i++){
ss.getRange(lastRow+1, i+1).setValue(data[i]);
}
Logger.log(data[0]);
return 0
}
Java脚本,Html和CSS代码:
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
window.addEventListener('load', function() {
google.script.run.withSuccessHandler(getData).setData();
});
function getData(data) {
var data = [];
data[0] = document.getElementById("InputName").value;
data[1] = document.getElementById("InputEmail").value;
data[2] = document.getElementById("Inputtel").value;
data[3] = document.getElementById("InputCPFCNPJ").value;
data[4] = document.getElementById("InputEnterprise").value;
data[5] = document.getElementById("InputMessage").value;
for(var i = 0; i < 6; i++){
if(data[i]=="" || data[i]==null){
window.alert("Não deixe campos vazios por favor.");
return 0;
}
}
google.script.run.setData(data);
return 0;
}
</script>
<html lang="pt-br">
<body>
<!-- Google Tag Manager -->
<noscript>
<iframe src="//www.googletagmanager.com/ns.html?id=GTM-TZFKJJ"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start' : new Date().getTime(),
event : 'gtm.js'
});
var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = '//www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-TZFKJJ');
</script>
<!-- End Google Tag Manager -->
<form role="form">
<div class="form-group col-xs-12">
<label class="sr-only" for="InputName">Nome</label>
<input type="text" class="form-control" id="InputName" placeholder="Nome">
</div>
<div class="form-group col-xs-12">
<label class="sr-only" for="InputEmail">Email</label>
<input type="email" class="form-control" id="InputEmail" placeholder="e-mail">
</div>
<div class="form-group">
<div class="form-inline">
<div class="form-group col-xs-6">
<label class="sr-only" for="Inputtel">Telefone</label>
<input type="tel" class="form-control" id="Inputtel" placeholder="Telefone">
</div>
<div class="form-group col-xs-6">
<label class="sr-only" for="InputCPFCNPJ">CPF ou CNPJ</label>
<input type="number" class="form-control" id="InputCPFCNPJ" placeholder="CPF ou CNPJ">
</div>
</div>
</div>
<div class="form-group col-xs-12">
<label class="sr-only" for="InputEnterprise">Empresa</label>
<input type="text" class="form-control" id="InputEnterprise" placeholder="Empresa">
</div>
<div class="form-group col-xs-12">
<label class="sr-only" for="InputMessage">Mensagem</label>
<textarea class="form-control" rows="3" id="InputMessage" placeholder="Mensagem"></textarea>
</div>
<div class="form-group col-xs-2">
<button class="btn btn-default" type="submit" onclick="getData();">
Enviar
</button>
</div>
</form>
</body>
</html>
答案 0 :(得分:1)
如果您阅读htmlService上的官方文档,caja部分,您会看到它说不允许使用iframe。