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).
Asked
Active
Viewed 2,271 times
0
-
4Try this : window.location.protocol + "//" + window.location.host – Unnie Mar 05 '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
1 Answers
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