从Firefox中的IFRAME初始化下载后,奇怪的浏览器错误对话框

时间:2019-01-29 13:46:57

标签: javascript html firefox gwt smartgwt

当我尝试从隐藏的<iframe>元素初始化下载时,会弹出此对话框:

enter image description here

您在上方看到的不是alert()。这是一个本机浏览器对话框,我从未见过。

我会说代码很简单。它是在GWT代码中嵌入的javascript:

protected native void downloadLink(String url, IframeOnError onError, IframeOnSuccess onSuccess)/*-{
    console.log(url, onError, onSuccess);
    var tmpIframe = document.createElement("iframe");

    tmpIframe.style.position = "absolute";
    tmpIframe.style.width = "5px";
    tmpIframe.style.height = "5px";
    tmpIframe.style.top = "-10px";
    tmpIframe.onload = function() {
        console.log("Success cb:",onSuccess);
        onSuccess();
        document.body.removeChild(tmpIframe);
    };
    tmpIframe.onerror = function() {
        console.log("Error cb:",onError);
        onError();
        document.body.removeChild(tmpIframe);
    };
    console.log("Appending download <iframe>!",tmpIframe);
    tmpIframe.src = url;
    document.body.appendChild(tmpIframe);
}-*/;

我可以在开发工具中看到服务器的响应。标题看起来像这样:

HTTP/1.1 200 OK
Date: Tue, 29 Jan 2019 13:43:11 GMT
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Disposition: attachment; filename="denni.xlsx"
Content-Length: 87966

在其他任何浏览器中我都没有遇到过这种情况。其他浏览器运行正常。

0 个答案:

没有答案