我希望获得location.hash
部分,即%20
之后的单词。但是怎么样?
解释
http://localhost/text/search.php?search=sweet%20girl => girl
http://localhost/text/search.php?search=fashion => NULL
http://localhost/text/search.php?search=2011%20best%20and%20worst => best and worst
答案 0 :(得分:4)
var s = decodeURIComponent(location.search);
var index = s.indexOf(" ");
s = index === -1 ? s.substr(index + 1) : null;
答案 1 :(得分:0)