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();
<h1> Skype URI Scheme Browser Example:</h1> <p> Please change you username or use the default (echo123). The link actions will be automatically refreshed with the providen username: </p> <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>