jquery中怎么获取当前的路径
答案:4 悬赏:20 手机版
解决时间 2021-01-17 10:02
- 提问者网友:
- 2021-01-17 02:45
jquery中怎么获取当前的路径
最佳答案
- 五星知识达人网友:西岸风
- 2021-01-17 03:24
获得根目录
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 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);
}
全部回答
- 1楼网友:山有枢
- 2021-01-17 05:16
location.href
你是要问这个吗?
你是要问这个吗?
- 2楼网友:一把行者刀
- 2021-01-17 04:37
window.location或者location.href 都可以
- 3楼网友:鸠书
- 2021-01-17 03:47
直接用js就可以获取到window.location就可以获取到
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯