我的网址如下所示:
http://www.something.hu/#/ask?kerdesPost=fdasdas%20ad%20asd%20ad%20asdas
我只想fdasdas%20ad%20asd%20ad%20asdas
或kerdesPost=fdasdas%20ad%20asd%20ad%20asdas
。
我如何通过JavaScript完成?什么是最短路?
答案 0 :(得分:7)
您可以尝试以下操作:
if((window.location.href).indexOf('?') != -1) {
var queryString = (window.location.href).substr((window.location.href).indexOf('?') + 1);
// "queryString" will now contain kerdesPost=fdasdas%20ad%20asd%20ad%20asdas
var value = (queryString.split('='))[1];
// "value" will now contain fdasdas%20ad%20asd%20ad%20asdas
value = decodeURIComponent(value);
// "value" will now contain fdasdas ad asd ad asdas (unescaped value)
}
这可以满足您的需求。