Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

html - how to do to join the adress mail with "mailto", in javascript?

Using google app script, the adresse mail filled in the variable , from google sheet API and then, I want to join "mailto:" with the variable of adress mail . This allows to appear this variable in html . How to do it ?

in google app script:

var Email_user = Session.getActiveUser().getEmail();
          var hrefmail = "mailto:"+Email_user ;
          var val_htm_mail_1 =hrefmail ; 
:
:
:
 theHTML.linkEmail = val_htm_mail_1; ( this is to fill the variable "val_htm_mail_1" to send it to HTML

in html :

 <span id="linkEmail"><?=linkEmail?></span><br /> 

thank you in advance for this helpness

question from:https://stackoverflow.com/questions/65847907/how-to-do-to-join-the-adress-mail-with-mailto-in-javascript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I recommend using HTML DOM Edit HTML content instead of a scriptlet. Here's the w3 reference so you can try to write it yourself, instead of just copying mine. Here is an example program:

code.gs

function doGet() {
  return HtmlService.createTemplateFromFile('Index')
  .evaluate();
}
function include(filename) {
  var Email_user = Session.getActiveUser().getEmail();
  var hrefmail = "mailto:"+Email_user ;
  val_htm_mail_1 = hrefmail ;
  return HtmlService.createHtmlOutputFromFile(filename)
  .getContent();
}

Index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <span id="linkEmail">...</span><br/>
    <script>
      document.getElementById("linkEmail").innerHTML = this.val_htm_mail_1;
    </script>
    <?!= include ('javascript'); ?>
  </body>
</html>

javascript.html

<script>
window.addEventListener('load', function() {
  console.log('Page is loaded');
});
</script>

*Note you may need to adjust this depending on your browser settings


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...