没有基本href,我如何获取路径

How can i get path without base href?

本文关键字:何获取 获取 路径 href      更新时间:2023-09-26

在html中分配的基础,如下所示:

<base href="http://root/tempop/panel/"/>

当前浏览器URL为:

http://root/tempop/panel/about/1

我想要这个:

 about/1

我该怎么走?

var endPiece = document.location.href.split('http://root/tempop/panel/')[1];
var base = $("base").prop("href");
var fullurl = "http://root/tempop/panel/about/1"
var path = fullurl.replace(base,"");
console.log(path)

http://jsfiddle.net/57gbetwp/