Toran Billups Toran Billups - 3 months ago 5
jQuery Question

Does jQuery have a built in function to return the rootURL?

I typically use the below function to return the root URL if I ever need this, but thought to ask if jQuery had a "one liner" way to do this ...

function getRootURL()
{
var baseURL = location.href;
var rootURL = baseURL.substring(0, baseURL.indexOf('/', 7));

// if the root url is localhost, don't add the directory as cassani doesn't use it
if (baseURL.indexOf('localhost') == -1)
{
return rootURL + "/AppName/";
} else {
return rootURL + "/";
}
}

Answer

What about

document.location.hostname