我试图使用Skype与HTML和爪哇脚本进行聊天。这里的问题是我无法将属性href添加到我的id中。
这里我的代码:
function el(elementId, username, action) {
document.getElementById(elementId).setAttribute("href", "skype:" + username + "?" + action);
}
function buildLinkRefs() {
var username = document.getElementById("username").value;
el("call-btn", username, "call");
el("add-to-contacts-btn", username, "add");
el("view-profile-btn", username, "userinfo");
el("voice-email-btn", username, "voicemail");
el("chat-btn", username, "chat");
el("sendfile-btn", username, "sendfile");
}
document.getElementById("username").addEventListener("change", function () {
buildLinkRefs();
}, false);
buildLinkRefs();
<input type="text" id="username" value="echo123"/><br>
<br>
<a id="call-btn">Call</a> <br>
<a id="add-to-contacts-btn">Add to contacts</a> <br>
<a id="view-profile-btn">View User Profile</a> <br>
<a id="voice-email-btn">Voice Email</a> <br>
<a id="chat-btn">Start Chat</a> <br>
<a id="sendfile-btn">Send File</a> <br>
翻过高山走不出你
青春有我
相关分类