简体   繁体   English

如何在javascript中的超链接之间添加变量值

[英]How to add an variable value in between the hyperlink in javascript

I am sending an email via javascript. 我正在通过javascript发送电子邮件。 In mail.parameter.text property I need to send the hyperlink. mail.parameter.text property我需要发送超链接。 In the code below I am hardcoding the url whick looks very lengthy and also I need to add the /dashboard at the end of the url. 在下面的代码中,我正在对url进行硬编码,看起来很长,而且我需要在url的末尾添加/dashboard Any idea on how to shorten the url? 关于如何缩短网址的任何想法?

var parent = space.getParent();
var siteGroup = "GROUP_EMAIL_CONTRIBUTORS";
var mail = actions.create("mail");
mail.parameters.to_many = siteGroup;
mail.parameters.subject="New Site Created in Community"
mail.parameters.text=" A new site called " + document.properties.name +"is created.Click http://pc1:8080/share/page/site/"+document.properties.name+"/dashboard"+"   to join the site";

//execute action against a document
mail.execute(document);

Sorry if this is a basic question I dont know javascript. 抱歉,如果这是我不懂javascript的基本问题。 This is my entire script and I am not using any html tags in between. 这是我的整个脚本,两者之间没有使用任何html标记。

You can change it to something like this, for example: 您可以将其更改为如下所示:

mail.parameters.text="Click <a href='http://pc1:8080/share/page/site/" + document.properties.name + "/dashboard'>here</a>";

Your link will appear as "here" and nevertheless lead to the URL you specified. 您的链接将显示为“此处”,但仍指向您指定的URL。 Is that what you mean by "shorten the url"? 这是“缩短网址”的意思吗?

Please try now. 请立即尝试。

var url = "Click http://pc1:8080/share/page/site/" + document.properties.name + "/dashboard" + "   to join the site";
ail.parameters.text = url;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM