开发者

href javascript function call auto decoding issue

<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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜