无法在网页中打开文件

时间:2017-07-18 04:16:49

标签: javascript html angularjs

我的要求是在网页中打开pdf文件。下面的代码用于在浏览器中显示pdf文件(chrome和IE)。 但问题是IE ,在pdf文件打开之前会显示一个警告框,表示拒绝访问被拒绝。请使用以下代码建议如何在Internet Explorer中打开pdf文件 没有显示警告框(访问被拒绝).html代码:

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if things.count == 0 {
        self.tableView.setEmptyMessage("My Message")
    } else {
        self.tableView.restore()
    }

    return things.count
}

js code:

<div ng-controller="myPDFFileController">
<object ng-if="!IEBrowser" data="{{content}}" type="application/pdf" style="width: 100%; height: 1200px;overflow-y: hidden; cursor:pointer;"></object> 
<iframe ng-if="IEBrowser" id ="pdfIframe" ></iframe>
</div>

- 编辑 -

//服务电话

app.controller('myPDFFileController', function ($scope,MyAppService) {
      $scope.getPDFPathFileName  = function () {
             MyAppService.getPDFPathFileName().then(
            function (response) {
                if(window.navigator.msSaveOrOpenBlob){
                   $scope.IEBrowser = true;
                    $scope.content = response;
                    $timeout(function() {
                        $scope.content = response;
                        document.querySelector('#pdfIframe').setAttribute('src',$scope.content);
                    }, 0);
                } else {

                    $scope.IEBrowser = false;
                    $scope.content = response;
                }
            },
            function (errResponse) {
                $rootScope.showError("Internal error" + errResponse);
            });
     }
      $scope.getPDFPathFileName();
});
js控制器中的

响应是/resources/myfiles/abc.pdf

0 个答案:

没有答案
相关问题