这里还是一个javascript新手。我正在创建一个小脚本,在网格左侧显示登录用户,在右侧显示一组图像。我根据需要设置了HTML all并让我的登录用户正常运行。
我的问题是......
如何让函数loggiedinuser
将结果显示在Div标记loggedinuser
中。以下是我的代码。
希望我已经正确解释了这一点。
由于
杰克
function doGet() {
return HtmlService
.createTemplateFromFile('grids')
.evaluate();
}
function loggedinuser() {
var userEmail = Session.getActiveUser().getEmail();
var username = userEmail.substring(0, userEmail.indexOf("@"));
var usernameUppercase = username.toUpperCase();
var HTMLString = "<body> <h3> Logged in as " + usernameUppercase + "</h3></body>";
}
.wrapper {
display: grid;
grid-template-columns: 20% 80%;
}
.wrapper>div {
background: #eee;
padding: 1em;
}
.wrapper>div:nth-child(odd) {
background: #ddd;
}
.apps ul {
vertical-align: middle;
list-style-type: none;
}
.apps li {
float: left;
padding-left: 14%;
}
.apps img {
overflow: auto;
}
.apps img:hover {
background-color: blue;
padding: 30%;
}
.apps a {}
<html>
<body>
<div class="wrapper">
<div class="loggedin">
</div>
<div class="apps">
<ul>
<li>
<a href="https://mail.google.com/a/">
<img border="0" alt="Gmail" src="https://drive.google.com/uc?export=view&id=1UXYyAO52U3kY4oVYYpaY__Z8kN8VHFxN" width="40" height="40">
</a>
</li>
<li>
<a href="https://drive.google.com/a/">
<img border="0" alt="Google Drive" src="https://drive.google.com/uc?export=view&id=1I53gryIOd2-PYtINtLDjY_SNjzw3AP1w" width="40" height="40">
</a>
</li>
<li>
<a href="https://www.google.com/calendar/hosted/">
<img border="0" alt="Google Calendar" src="https://drive.google.com/uc?export=view&id=18ZLAHw-ygNpPB6ykZV8zVjap1qcyAmuY" width="40" height="40">
</a>
</li>
<li>
<a href="https://classroom.google.com">
<img border="0" alt="Google Classroom" src="https://drive.google.com/uc?export=view&id=1oHMpEX8HKNxIOgOY12N_VTrqc3PdX654" width="40" height="40">
</a>
</li>
<li>
<img class="appsicon" border="0" src="https://drive.google.com/uc?export=view&id=17wU1CyojZMixcv6g3j5mKBnFbs_JCkGL" onclick="myFunction()" width="40" height="40">
</li>
</ul>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
试试这个:
<div class="loggedin">
<?!= loggedinuser() ?>
</div>
function loggedinuser() {
var userEmail = Session.getActiveUser().getEmail();
var username = userEmail.substring(0, userEmail.indexOf("@"));
var usernameUppercase = username.toUpperCase();
return "<body> <h3> Logged in as " + usernameUppercase + "</h3></body>";
}