【发布时间】:2015-01-02 13:16:06
【问题描述】:
我正在使用 AngularJS 并在 iframe 上设置 ngSrc,我用它来下载压缩存档以解决无法使用 AJAX 下载文件的问题。我正在使用一个指令来检测我发现here 的 iframe 负载,当您加载像“about:blank”这样的 URL 时,它工作得很好,但是当我用 RESTful 调用它时它没有负载下载文件,即使它下载了生成的文件。
// Markup of iframe using ngSrc and custom directive
<iframe ng-src="{{url}}" style="display:none;" iframe-onload="myCallback" />
// Controller setting iFrame, what I'd like to trigger the load
$scope.downloadArchive = function( id ) { // no load event? but downloads zip archive
var url = '/data/archive/instance/' + id;
$scope.url = $sce.trustAsResourceUrl( url );
}
// Controller setting iFrame, what does trigger the load
$scope.downloadArchive = function( id ) { // load event triggered
$scope.url = $sce.trustAsResourceUrl('about:blank');
}
通过 iframe 下载压缩存档时是否可以检测到事件?
【问题讨论】:
标签: javascript jquery html angularjs iframe