admin管理员组文章数量:1402587
I am trying to get a text input field whose value gets sent as the parameter for an XSL transformation which is performed in JavaScript. I have set up a form with the get method, and my script gets the URL parameter like this:
var word=unescape((''+self.location.search).substring(5)).toLowerCase();
This works fine, except when the input contains special characters. I have set the HTML page's encoding to UTF-8, and I have added
accept-charset="utf-8"
to the form. I have also specified charset="utf-8" in the script tag, but it still doesn't work. My browser (Firefox) is set to UTF-8 as the default encoding. I have tried removing the unescape function too.
I am trying to get a text input field whose value gets sent as the parameter for an XSL transformation which is performed in JavaScript. I have set up a form with the get method, and my script gets the URL parameter like this:
var word=unescape((''+self.location.search).substring(5)).toLowerCase();
This works fine, except when the input contains special characters. I have set the HTML page's encoding to UTF-8, and I have added
accept-charset="utf-8"
to the form. I have also specified charset="utf-8" in the script tag, but it still doesn't work. My browser (Firefox) is set to UTF-8 as the default encoding. I have tried removing the unescape function too.
Share Improve this question edited May 22, 2012 at 10:23 KooiInc 123k32 gold badges145 silver badges181 bronze badges asked May 22, 2012 at 9:46 corfizzcorfizz 331 silver badge5 bronze badges1 Answer
Reset to default 5try
decodeURIComponent()
instead of
unescape
see @ http://www.w3schools./jsref/jsref_decodeuriponent.asp
本文标签: utf 8Getting UTF8 URL parameter with JavaScriptStack Overflow
版权声明:本文标题:utf 8 - Getting UTF-8 URL parameter with JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744363726a2602670.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论