/**
* 获取当前工程的虚拟目录
* @return
*/
function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var pos=strFullPath.indexOf(strPath);
var prePath=strFullPath.substring(0,pos);
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
return(prePath+postPath);
}
var _base = getRootPath();
/**
* 移除数组指定位置上的元素
* i: 要移除的数组元素小标
*/
Array.prototype.removeByIndex = function(i){
if (i < this.length && i >= 0) {
var ret = this.slice(0, i).concat(this.slice(i + 1));
this.length = 0;
this.push.apply(this, ret);
}
}
js中两个常用方法(1.获取当前工程的虚拟目录;2.移除数组指定位置上的元素)
最新推荐文章于 2019-04-23 09:25:00 发布