Javascript createObjectURL无法在Android浏览器中运行

时间:2015-11-02 21:42:57

标签: javascript android android-webview android-browser

为什么我不能在带有webview的Android应用程序中下载使用createObjectUrl创建的文件。使用默认浏览器(三星Galaxy S6 Edge)也是不可能的。我收到消息(瑞典语)“Endast http- eller https-URL:erkanämtas。”,翻译:只能获取http或https网址。

HTML

<textarea id="editor">Hello, world!</textarea>
<a download="myFile.txt" id="fileSaver">Save as...</a>

的Javascript

function updateLink() {
  var editor = document.getElementById("editor"),
    fileSaver = document.getElementById("fileSaver"),
    blob = new Blob([editor.value], { type: "text/plain" });

  fileSaver.href = (window.URL || window.webkitURL).createObjectURL(blob);
}
updateLink();
fileSaver.onclick = fileSaver.oncontextmenu = updateLink;

JSFiddle:this is compatible with linux

0 个答案:

没有答案