我试图运行此代码:
var input = document.getElementById("input");
var processor = document.getElementById("processor");
var output = document.getElementById("output");
window.addEventListener("message", function(event){
if (event.source != processor.contentWindow) return;
switch (event.data){
case "ready":
var xhr = new XMLHttpRequest;
xhr.open('GET', input.getAttribute("src"), true);
xhr.responseType = "arraybuffer";
xhr.onload = function(event) {
processor.contentWindow.postMessage(this.response, "*");
};
xhr.send();
break;
default:
output.textContent = event.data.replace(/\s+/g, " ");
break;
}
}, true);
我收到以下错误:
交叉源请求仅支持协议方案:http,数据,chrome,chrome-extension,https,chrome-extension-resource。
有解决方法吗?