【问题标题】:Uncaught URIError: URI malformed with reCAPTCHA未捕获的 URIError:使用 reCAPTCHA 格式错误的 URI
【发布时间】:2015-12-08 08:19:47
【问题描述】:

在某些 URL 中有编码部分的页面上,例如 %FC 而不是 ü,我在控制台中收到 Uncaught URIError: URI malformed 错误,因此验证码无法正常工作。

我们的项目是iso-8859-1 编码的,对此我无能为力。

您知道可以解决此问题的解决方法吗?我正在使用 reCAPTCHA 2。

【问题讨论】:

    标签: javascript iso-8859-1 recaptcha


    【解决方案1】:

    我现在的解决方案是,在执行recaptcha/api.js 之前,我抓住window.location.pathname,去掉有问题的元素并在url 中将其与history.pushState 交换。如果我只是更改window.location.pathname 页面重定向将是结果。

    这是我的示例代码:

    var oldPath = window.location.pathname;
    var newPath = decodeURIComponent( unescape( unescape(oldPath)));
    var stateObj = {};
    history.pushState(stateObj, "", newPath);
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 1970-01-01
      • 2020-07-01
      • 2020-04-16
      • 2014-10-18
      • 2011-08-16
      • 1970-01-01
      • 2016-09-14
      • 2014-07-26
      相关资源
      最近更新 更多