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:

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