I am trying to get my applications root URL from within a .js file. A solution I came upon suggested to use:
window.location.origin
However, because the site is hosted in a virtual directory in IIS, that only returns http://www.whatever.com, but I need it to return http://www.whatever.com/mydir. This might seem like simple string parsing, but I debug using localhost where there is no virtual dir, so I need a solution that is available from with a .js file (not a script block within an HTML document) and is dynamic in that it will work with and without a virtual directory.
window.location.origin + '/' + window.location.pathname.split('/')[1]