这是在开发国际机票查询页时碰到的一个问题,测试工程师在IE里执行查询操作,然后把查询的url赋值到firefox的地址栏,firefox打开后就变成乱码了。
1. IE浏览器,选择出发地,出发日期等后点击下查询
2. 跳转到查询页,复制下IE浏览器里的URL
3. 拷贝到Firefox/Chrome浏览器地址栏,会看到乱码
对比看下IE和Firefox的URL情况发现是由于location.href方式在IE中没有进行URI编码,改成form提交后就好了。
IE6-11
http://ijipiao.jd.com/international/query.action?_charset_=gbk&journeyType=RT&gjdepCity=北京&gjarrCity=香港&gjdepDate=2015-01-01&firstJourney.depCityName=北京&firstJourney.arrCityName=中文/拼音&firstJourney.depDate=&secondJourney.depCityName=中文/拼音&secondJourney.arrCityName=中文/拼音&secondJourney.depDate=&gjarrDate=2015-01-05&seatType=ECONOMY&passengerType=0&adtNum=1&chdNum=0&carrier=&carrierShow=不限&availableJourney=undefined&directOnly=false
Firefox/Chrome
http://ijipiao.jd.com/international/query.action?_charset_=gbk&journeyType=RT&gjdepCity=%B1%B1%BE%A9&gjarrCity=%CF%E3%B8%DB&gjdepDate=2015-01-02&firstJourney.depCityName=%B1%B1%BE%A9&firstJourney.arrCityName=%D6%D0%CE%C4/%C6%B4%D2%F4&firstJourney.depDate=&secondJourney.depCityName=%D6%D0%CE%C4/%C6%B4%D2%F4&secondJourney.arrCityName=%D6%D0%CE%C4/%C6%B4%D2%F4&secondJourney.depDate=&gjarrDate=2015-01-07&seatType=ECONOMY&passengerType=0&adtNum=1&chdNum=0&carrier=&carrierShow=%B2%BB%CF%DE&availableJourney=undefined&directOnly=false