我正在尝试从链接中删除URI编码,但decodeURI似乎没有完全正常工作.
我的示例链接是这样的:/ linkout?remoteUrl = http%3aa%2f%2fsandBox.yoyogames.com%2fgames%2f171985-h-a-m-heroic-armies-marching
运行JavaScript脚本后,它看起来像这样:
http%3a%2f%2fsandBox.yoyogames.com%2fgames%2f171985-h-a-m-heroic-armies-marching
如何摆脱URI中剩余的不正确的代码?
我的解码代码:
var href = $(this).attr('href'); // get the href var href = decodeURI(href.substring(19)); // remove the outgoing part and remove the escaping $(this).attr('href','http://'+href) // change link on page