您好我正在使用此代码来获取此路径: http://192.168.1.5:83/staging/eleave/application/view/leave_approval.php
var url = document.location.toString();
问题是如何才能获得此路径? : http://192.168.1.5:83/staging/eleave/application/
答案 0 :(得分:0)
如果您知道网址中需要多少个文件夹,那么:
var splittedUrl = url.split("/");
var depth = 5;
var neededUrl = '';
for (i = 0; i < depth; i++)
{
neededUrl += splittedUrl[i] + '/';
}