How to go to URL within same domain in Javascript

Deutsch English

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

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

Check out similar posts by category: Javascript