Javascript js,如何在location.hash中获取一个部件
我想获取Javascript js,如何在location.hash中获取一个部件,javascript,Javascript,我想获取位置。哈希部分,第一个%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 首先使
位置。哈希
部分,第一个%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
首先使用该函数。之后,您可以执行regexp
首先使用该函数。之后,您可以执行regexp
var s = decodeURIComponent(location.search);
var index = s.indexOf(" ");
s = index === -1 ? s.substr(index + 1) : null;
var url = "http://localhost/text/search.php?search=2011%20best%20and%20worst";
alert (unescape(url).replace(/^\S* /,""));