我在我网站的个人资料页面上有这样的代码。
<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>
Run Code Online (Sandbox Code Playgroud)
这是使用 EJS 完成的。它们基本上是具有用户社交页面 URL 字符串的 href 标签。后端是一个MongoDB
问题 - 如果我在数据库的相应字段中输入有效 URL,我将被重定向到正确的 URL。但是,如果字符串为空,则它会向 /profile/:username 发布 GET …