获取url中的中文

中文如果通过url传给第二个页面。可能会出现乱码的问题。

window.location.href="/html/module/receiveMes/sendMes1.html?mailGid="+mailGid+"&createrName="+createrName+"&createrGid="+createrGid;

createrName是个中文的汉字。


在传的时候就会变成http://localhost/html/module/receiveMes/sendMes1.html?mailGid=241ee5fe672fe7302379e803758b7ac5&createrName=%E5%B0%8F%E7%B1%B3&createrGid=9d4996738944b03c721ca4714e9ee96b

如果通过一般的方式window.location.href

整个URl字符串(在浏览器中就是完整的地址栏)根本获取不到.你需要先进行

转码:decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码。

createrName=decodeURI(location.href).split('&')[1].split('=')[1];




版权声明:本文为qq_33769914原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。