encodeURIComponent behaves differently in browsers for china as location

折月煮酒 提交于 2019-12-07 08:10:55

问题


i have an interesting problem in hand that involves chinese..

i use google custom search and append searched keywords as below..

window.location="http://search.xyz.com/search/cn/zh"+"#"+encodeURIComponent(searchedKeywords);

  1. results in chrome and internet explorer for 搜索 are proper but in firefox no results appear..
  2. in chrome and internet explorer, url created is http://search.xyz.com/search/cn/zh#%E6%90%9C%E7%B4%A2
  3. in firefox, url created is http://search.xyz.com/search/cn/zh#%u641C%u7D22
  4. in chrome and internet explorer, search box that appears in the result page has value æç´¢
  5. in firefox, search box that appears in the result page has value 搜索
  6. in all three browsers, if i search with any valid chinese words, no result appear..

i do include below elements in the file..

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="Content-Language" content="zh-CN" />

since the query is formed in the browser using script, my tomcat server is not involved, so we can rule that out..

now how do i show 搜索 in search box in result page of chrome and internet explorer and also achieve the search with valid chinese words..

highly appreciate your help..

来源:https://stackoverflow.com/questions/7715912/encodeuricomponent-behaves-differently-in-browsers-for-china-as-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!