HREF行为-需要明确

问题描述 投票:1回答:1

希望有人可以快速帮助我。我的网站的个人资料页面上有类似的代码。

<div class="col-md-4">
    <h2 class="textclass2" style="text-decoration: underline; margin-bottom: 10px"><%=playerdata.Player_Name%>   AKA  <%=playerdata.Player_NickName%></h2>
    <a class="btn btn-dark btn-xs" href="<%=playerdata.Player_FBLink%>" id="fbclick" onClick="checkUrl()" style="font-size: 12px; color:#40FF40; margin-bottom: 10px "> Facebook </a>
    <a class="btn btn-dark btn-xs" href="<%=playerdata.Player_InstagramLink%>" role="button" style="font-size: 12px; color:#40FF40; margin-bottom: 10px"> Instagram </a>
    <a class="btn btn-dark btn-xs" href="<%=playerdata.Player_LinkedinProfile%>" role="button" style="font-size: 12px; color:#40FF40; margin-bottom: 10px"> LinkedIN </a>
    <a class="btn btn-dark btn-xs" href="<%=playerdata.Player_TwitterLink%>" role="button" style="font-size: 12px; color:#40FF40; margin-bottom: 10px"> Twitter </a>

这是使用EJS完成的。它们基本上是HREF标记,具有用户社交页面的URL字符串。后端是MONGODB

问题-如果我在数据库的相应字段中输入有效的URL,我将被重定向到正确的URL。但是,如果字符串为空,则将GET请求发布到/ profile /:用户名。

这是HREF标签通常的行为方式。如果是,该如何规避。基本上,如果字符串为空,则我不想执行GET调用,而只是向用户显示一条消息,说字符串为空。有人可以给点灯吗?

javascript href ejs
1个回答
0
投票

如果没有href,则其行为将类似于。如果有一个空白href,它将从地址栏中的任何URL继承它。因此,如果没有发言权,则根本不打印链接。 Twitter链接

© www.soinside.com 2019 - 2024. All rights reserved.