动态加载iframe时get请求传递中文参数乱码解决方法

时间:2014-05-07    点击:108   
当用户的页面需要动态加载iframe 时,

如果iframe的src中包传中文参数会出现编码错误;必须加编码,然后再解码。

编码:encodeURI(encodeURI("包含中文的串"))

解码:java.net.URLDecoder.decode("需要解码的串","utf-8");

解决方案

使用 encodeURI('中文') 进行编码操作,

js代码:
复制代码 代码如下:

$(function() {
$('#frame').attr('src', '${basePath}mi/right.do?bidItemName=' +encodeURI('中文'));
});

html代码
复制代码 代码如下:

<html>
<body>
<iframe src="" scrolling="no" frameBorder=0 id="frame"></iframe>
</body>
</html>
解决jQuery动态获取手机屏幕高和宽的问题
addEventListener 的用法示例介绍
jquery通过select列表选择框对表格数据进行过滤示例
关闭时刷新父窗口两种方法
js获取下拉列表的值和元素个数示例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved