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'
.
精彩评论