var str1='/qihoo/app/a/b/c/d/e/new.html';
var str2='/qihoo/app/1/2/3/test.html';
function changeToRelative(str1,str2){
var arr1=str1.split('/');
var arr2=str2.split('/');
var arr=[];
for(var i=0;i<arr2.length;i++){
while(arr1[i]===arr2[i]){
arr1.shift();
arr2.shift();
}
}
for(var j=0;j<arr1.length-1;j++){
arr.push('../');
}
arr=arr.join('').concat(arr2.join('/'));
return arr;
}
console.log(changeToRelative(str1,str2));