现在的位置: 首页 > 综合 > 正文

获取当前页面的地址 JS

2018年01月29日 ⁄ 综合 ⁄ 共 269字 ⁄ 字号 评论关闭
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);

var path = prePath + postPath;

试验过的 获取前半部分地址

抱歉!评论已关闭.