using
document.location.origin+document.location.pathname;
where document.location.origin redirect you to "http://www" and document.location.pathname redirect you to "/ stackoverflow /" (the name of your project). That way you can provide a link to a page or post in the js file. Please, if I want a link to my home page, I would use
var address=document.location.origin+document.location.pathname; window.location.replace(address+"/home");
Thus, using the example above, I can easily redirect to the home page
Er.Naved Ali
source share