如何在href下面的代码中创建链接?我似乎无法使它成为可点击的链接

问题描述 投票:0回答:3
user = "1401";
document.write("User|"+CallSINIMethod("GetValue", ["UserField", "UserProfileFirstName", user])+"|<br><br>");


docs = CallSINIMethod("GetListValue", ["UserListProperty", "OrderedDocuments", user]);

i = 0;

while (i < docs.length) {

    document.write(CallSINIMethod("GetValue", ["DocumentProperty", "ProductName", docs[i]])+"|"+docs[i]+"|<br>");
    document.write("http://goodsamstorefront.com/goodsamstorefront/GetProof.aspx?id="+docs[i]+"<br>");
    document.write(CallSINIMethod("GetValue", ["VariableValue", "__DateUpdatedInCart", docs[i]])+"<br>");
    document.write(CallSINIMethod("GetValue", ["VariableValue", "__DocumentStatus", docs[i]])+"<br>");
    document.write(CallSINIMethod("GetValue", ["DocumentProperty", "EditingStatus", docs[i]])+"<br><br/>");
    i++;
}
javascript html
3个回答
0
投票

要使链接可单击,您应该使用<a>标记。例如:

<a href="https://google.com">https://google.com</a>

这是一个链接,谷歌和“https://google.com


0
投票

你需要创建一个<a></a>标签,如下所示:

document.write("http://goodsamstorefront.com/goodsamstorefront/GetProof.aspx?id=1<br>");
document.write("<a href='http://goodsamstorefront.com/goodsamstorefront/GetProof.aspx?id=1'>I am a Link</a><br>");

0
投票

document.write如下所示应该有效

document.write("<a href=http://goodsamstorefront.com/goodsamstorefront/GetProof.aspx?id="+docs[i]+"></a>");

或者你可以创建一个元素

var a = document.createElement('a');
a.setAttribute('href',link);
a.innerHTML = text;

并追加,但它是一个漫长的方式

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