解码url里的gbk汉字编码
function urldecode(str, charset, callback) {
window._urlDecodeFn_ = callback;
var script = document.createElement('script');
script.id = '_urlDecodeFn_';
var src = 'data:text/javascript;charset=' + charset + ',_urlDecodeFn_("' + str + '");'
src += 'document.getElementById("_urlDecodeFn_").parentNode.removeChild(document.getElementById("_urlDecodeFn_"));';
script.src = src;
document.body.appendChild(script);
}
urldecode('%C3%C0%B0%D7%EC', 'gbk', function(d) {
console.log(d);
});