You can get the protocol and the host separately, and then join them to get what you need
window.location.protocol + "//" + window.location.host + "https://stackoverflow.com/"
As a sidenote, window.location.pathname
would contain the path.
You can get the protocol and the host separately, and then join them to get what you need
window.location.protocol + "//" + window.location.host + "https://stackoverflow.com/"
As a sidenote, window.location.pathname
would contain the path.