我怎样才能通过javascript读取url的GET元素?
这个问题在这里已经有了答案:
您可以尝试以下方法:
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)
}
的jsfiddle
这应该让你得到你所需要的。
链接地址: http://www.djcxy.com/p/17615.html