我怀疑apps脚本服务器中存在某些卫生过程,阻止onclick命令将值传递给该函数。有没有解决的办法? 这是我所拥有的:
function func() {
var template = HtmlService.createHtmlOutputFromFile('buttons');
var content = (template.getContent());
Logger.log(content)
MailApp.sendEmail({
to: 'ggg@gmail.com',
subject: 'subject',
htmlBody: content
});
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Answer: <input type="text" id="myText" value="Try one button below">
<p>Try one of the answers below</p>
<button value='ttt' onclick="f1(this)">Try it</button>
<button value='ggg' onclick="f1(this)">Try it</button>
<button value='hhh' onclick="f1(this)">Try it</button>
<button value='eee' onclick="f1(this)">Try it</button>
<script>
function f1(obj){
if (obj.value == 'ttt'){
document.getElementById("myText").value = 'Correct!';
}
else{
document.getElementById("myText").value = 'Wrong answer..';
}
}
</script>
</body>
</html>
答案 0 :(得分:1)
现代电子邮件客户端/服务不允许在电子邮件的HTML内容上使用AFAIK JavaScript,因为它具有安全风险。
相关