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).

KhalilG
  • 686
  • 1
  • 8
  • 20

1 Answers1

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;
    }
Taran Goel
  • 4,474
  • 5
  • 20
  • 44