我通常使用下面的函数来返回根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 + "/";
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13671 次 |
| 最近记录: |