0

I'm looking for a "beautiful" and the fastest way to get only the web application url (don't want to trim or substring or anything else).

  • 4
    Try this : window.location.protocol + "//" + window.location.host – Unnie Mar 5 '15 at 13:39
  • Unnie, can you make this an answer so you get your due credit? – Eric Alexander Jun 11 '15 at 13:01
0

You can use the below code to find WebApp url, this takes care of port number too (if exists)

var WebAppUrl="";
if (location.port)
    {
        WebAppUrl = window.location.protocol + "//" + window.location.host + ":" + location.port;
    }
    else
    {
        WebAppUrl = window.location.protocol + "//" + window.location.host;
    }

Not the answer you're looking for? Browse other questions tagged or ask your own question.