Url编码的Javascript问题

时间:2015-11-09 18:42:55

标签: javascript jquery

因此,在Url编码的Javascript(javascript:[js])中,代码中的非ASCII字符(例如jQuery选择器中的括号和空格)被无意中编码。

知道如何解决这个问题吗?

正常: $('.panel-default:first div h3 table tbody tr td div ul li:last a').attr('onclick').replace("DELETECPRO", "MIGRATECACPRO");

网址编码: %24%28%27.panel-default%3Afirst+div+h3+table+tbody+tr+td+div+ul+li%3Alast+a%27%29.attr%28%27onclick%27%29.replace%28%22DELETECPRO%22%2C+%22MIGRATECACPRO%22%29%3B

1 个答案:

答案 0 :(得分:0)

尝试:

decodeURIComponent("%24%28%27.panel-default%3Afirst+div+h3+table+tbody+tr+td+div+ul+li%3Alast+a%27%29.attr%28%27onclick%27%29.replace%28%22DELETECPRO%22%2C+%22MIGRATECACPRO%22%29%3B")
.replace(/\+/g, " ")