Why use ~? At first glance, I would say that removing it solves your problem. Like this.
document.location.href = "/Login.appx?ReturnUrl=" + ParentUrl;
[EDIT] replies to the first comment ...
I believe this can do the trick:
function getLoginPage() { var urlParts = document.location.href.split("/"); return "/" + urlParts[2] + "/" + urlParts[3] + "/Login.aspx"; } document.location.href = getLoginPage() + "?ReturnUrl=" + ParentUrl;
source share