js中判断空及获取当前服务的根路径

时间:2023-03-09 03:05:41
js中判断空及获取当前服务的根路径

function isValue(o) {
return (this.isObject(o) || this.isString(o) || this.isNumber(o) || this.isBoolean(o));
}
function isString(o) {
return typeof o === 'string';
}
function isObject(o){
return (o && (typeof o === 'object' || $.isFunction(o))) || false;
}
function isNumber(o) {
return typeof o === 'number' && isFinite(o);
}

function isBoolean(o) {
return typeof o === 'boolean';
}
function isEmpty(o) {
if (!this.isString(o) && this.isValue(o)) {
return false;
} else if (!this.isValue(o)) {
return true;
}
o = $.trim(o).replace(/\&nbsp\;/ig, '').replace(/\&#160\;/ig, '');
return o === "";
}

function getContextPath(){
var href=window.location.href;
var host=window.location.host;
var origin=document.location.origin;
var f1=href.substring(href.indexOf(host));
var f2=f1.substring(f1.indexOf("/"));
var root=f2.split("/");
return "/" + root[1];
//return "/easweb";
}