Javascript IE8中的解码组件错误

Javascript IE8中的解码组件错误,javascript,internet-explorer,internet-explorer-8,coffeescript,urlencode,Javascript,Internet Explorer,Internet Explorer 8,Coffeescript,Urlencode,我有一个作为iframe加载的小部件。它必须知道一些关于托管页面的数据。 我从页面中获得了几个UTF-8字符串。通常是几行俄语文本。页面本身符合适当的HTML5 doctype和meta字符集规范 然后我的代码是这样工作的: params = "x1=" + encodeURIComponent(s1) + "&x2=" + encodeURIComponent(s2) url = "http://mysite.com/iframe.html#" + params create_ifr

我有一个作为iframe加载的小部件。它必须知道一些关于托管页面的数据。 我从页面中获得了几个UTF-8字符串。通常是几行俄语文本。页面本身符合适当的HTML5 doctype和meta字符集规范

然后我的代码是这样工作的:

params = "x1=" + encodeURIComponent(s1) + "&x2=" + encodeURIComponent(s2)
url = "http://mysite.com/iframe.html#" + params

create_iframe(url)
其中create_iframe是一种

var $if, doc;

$if = $('<iframe>').attr({
  frameborder: 0,
  scrolling: "no",
  allowtransparency: "true"
}).css(css).appendTo($cont);

doc = $if[0].contentWindow.document;

doc.open().write("<head><meta charset=\"UTF-8\"><script>" +
    "var s = \"" + url + "\";" + // <--- here the url is injected into the iframe content
    "function init() { document.location.href = s; }" + 
     "</script></head><body onload=\"init();\">...</body>");

doc.close();
这整件事在Chrome中运行正常

在IE8中,当尝试解码URI时,我收到一个错误,说URI的编码无效


我应该如何解决这个问题?

答案是-IE截断了太长的URL,它发生在2个UTF-8字节之间。

这是什么语言?没有括号,没有分号,
decodeURIComponent
参数周围有括号?这些部分在CoffeeScript中(写在问题中),然后请显示CoffeeScript编译的输出。你能做一个
console.log(tmp[1])
?用编译的JS替换吗
var hash_index, loc, param, params, params_array, params_string, tmp, _i, _len;

loc = document.location.href;

hash_index = loc.indexOf('#');

if (hash_index >= 0) {
  params_string = loc.substring(hash_index + 1);
}

params_array = params_string ? params_string.split('&') : [];

params = {};

for (_i = 0, _len = params_array.length; _i < _len; _i++) {
  param = params_array[_i];
  tmp = param.split('=');
  params[tmp[0]] = decodeURIComponent(tmp[1]);
}

return params;