var elem = document.getElementById("URLHere") elem.innerHTML = correctURL; elem.setAttribute('href', correctURL);