js dorado 返回path

来源:互联网 发布:mac忘记密码怎么办 编辑:程序博客网 时间:2024/06/06 12:48
/**
 * 返回path
 * @returns
 */
function getPath(){
 /* 首先判断页面上是否有dorado对象,如果有则使用dorado中的上下文路径,否则采用自己解析的方式 */
 if (typeof(dorado) != "undefined"){
  //Dorado 7.1.16后,common.contextPath变成了contextPath
  var contextPath = dorado.Setting["common.contextPath"];
  if (!contextPath){
   contextPath = dorado.Setting["contextPath"];
  }
  //由于dorado 的contextPath在字符串的最后面多了一个/,需要去掉
  contextPath = contextPath.substring(0, contextPath.length - 1);
  return contextPath;
 }
 // 如果页面上baseurl不为空,则使用之
 if ("undefined" != typeof baseurl && baseurl != null) {
  return baseurl;
 }
   var path = window.location.pathname;
 var s = path.indexOf('/', 1);
 contextPath = path.substr(0, s);
 if (contextPath == "/") {
  contextPath = "";
 }
   return contextPath;
}
0 0
原创粉丝点击