【发布时间】:2009-01-08 15:19:00
【问题描述】:
如果我需要这个,我通常使用下面的函数来返回根 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 + "/";
}
}
【问题讨论】:
标签: javascript jquery