通常我使用以下函数来返回根URL,如果需要的话,但是想问一下jQuery是否有“一行代码”的方法来实现这个...
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 + "/";
}
}