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).
-
4Try this : window.location.protocol + "//" + window.location.hostUnnie– Unnie2015-03-05 13:39:18 +00:00Commented Mar 5, 2015 at 13:39
-
Unnie, can you make this an answer so you get your due credit?Eric Alexander– Eric Alexander2015-06-11 13:01:59 +00:00Commented Jun 11, 2015 at 13:01
Add a comment
|
1 Answer
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;
}