If you are not redirected automatically, document.getElementById("redirectLink").href = newDomain + window.location.pathname;