js change location code example Example 1: js change url window.location.href = "www.google.com"; Example 2: window replace url location.replace("url");