url字符串编码乱码问题

来源:互联网 发布:金税通网络电子发票 编辑:程序博客网 时间:2024/05/02 04:46
 function webChart() {            var t = document.getElementById("txtReceive");            if (t.value == null || t.value == "") {                alert("请先进行查询");            }            else {                              alert(t.value);                document.getElementById("center-iframe").src = "map/industryMap.aspx?_indeustry=" + t.value;}}

这个时候alert出来的编码很正常,都是汉字。

但是在后台获取时已经乱码

        protected void Page_Load(object sender, EventArgs e)        {            Industry = Request.QueryString["_indeustry"].ToString();            InitMap();            getShowMuilt();        }

 

web.config已经配置为UTF-8 但是还是不行

<system.web>    <globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8"                   responseEncoding="UTF-8" fileEncoding="UTF-8" />  </system.web>

 

 

最终解决方案

 function webChart() {            var t = document.getElementById("txtReceive");            if (t.value == null || t.value == "") {                alert("请先进行查询");            }            else {                var url = encodeURI("map/industryMap.aspx?_indeustry=" + t.value);                alert(url);                document.getElementById("center-iframe").src = url;}}

结果如下:


<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击