我使用
获得了一个网址var url = window.location.href;
console.log(url);
这是网址
http://www.myproject.com/wp/?edit_project=797#step2=project
现在我想从这个网址获取step2。任何线索如何只从网址获得这个。
答案 0 :(得分:0)
window.location.hash返回“#step2 = project”。你需要解析它(对url的hash部分没有限制)。
答案 1 :(得分:-3)
这将有效:
var startIndex = url.indexOf("step2");
var step2 = url.substr(startIndex);