首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

关于decodeURIComponent无法使用,该怎么处理

2012-05-16 
关于decodeURIComponent无法使用HTML codeform actiontool.html method get查找您想要的应用inp

关于decodeURIComponent无法使用

HTML code
<form action="tool.html" method = "get">      查找您想要的应用      <input name="searchFor" type="text" size="10" />      <input name="goButton" type="submit" value="搜索" />    </form>


我把这个get的值传到这个静态页面, 但是中文都是乱码 论坛上的大神说用decodeURIComponent这个方法进行解码。 不过我用了IE说是无效字符, 请求大神帮助。 别的方法也可以
HTML code
var qs = window.location.search.substring(1);var ar = qs.split('&');var tmp = ar[0].split('=');var str = decodeURI(tmp[1]);


[解决办法]
JScript code
//IE下执行下面这样代码会报错?不可能吧!alert(decodeURIComponent('%E6%B5%8B%E8%AF%95'));
[解决办法]
是的。你可以试一下。如果是gbk编码,你需要把经 encodeURIComponent() 编码后的值传递过去。那边才可以decodeURIComponent 解码。

热点排行