How to go to URL within same domain in Javascript

In order to go to an URL relative to the current domain name in Javascript, use window.location.origin like this:

example.js
window.location.href = window.location.origin + "/myurl"

Check out similar posts by category: Javascript