开发者

href javascript function call auto decoding issue

开发者 https://www.devze.com 2023-04-05 01:15 出处:网络
<a href=\"javascript:myfunc(\'hi%3dhi\')\"> </a> This passes text hi&hi to myfunc instead of hi%3dhi. Any way to solve this with out calling myf开发者_JAVA百科unc from onclickYou nee
<a href="javascript:myfunc('hi%3dhi')"> </a>

This passes text hi&hi to myfunc instead of hi%3dhi. Any way to solve this with out calling myf开发者_JAVA百科unc from onclick


You need to properly escape your string.
Specifically, you need to HTML-encode it, then URL-encode it, then Javascript-encode it.

The % character should be converted by the URL-escaping step to %25.


yes,

<a href="javascript: myfunc('hi%253dhi')"> </a>

just window.encodeURIComponent 'hi%3dhi'.

0

精彩评论

暂无评论...
验证码 换一张
取 消