utf 8 - Getting UTF-8 URL parameter with JavaScript - Stack Overflow

I am trying to get a text input field whose value gets sent as the parameter for an XSL transformation

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

try

decodeURIComponent()

instead of

unescape

see @ http://www.w3schools./jsref/jsref_decodeuriponent.asp

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744363727a4570596.html

相关推荐

  • utf 8 - Getting UTF-8 URL parameter with JavaScript - Stack Overflow

    I am trying to get a text input field whose value gets sent as the parameter for an XSL transformation

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信