javascript - 如何在 Bootstrap 模式对话框中嵌入外部 pdf?

标签 javascript jquery angularjs twitter-bootstrap pdf

我有一个外部 pdf 文件,我想将其嵌入到我的页面中显示。以下工作正常:

<object frame-resize data="www.cbu.edu.zm/downloads/pdf-sample.pdf" type="application/pdf" width="200px" height="200px"></object>

问题:我想在 modal 窗口中显示此嵌入的 pdf。但是一旦我将其移到那里,pdf就不再正确显示:

<a data-toggle="modal" data-target=".my-modal"></div>

            <div class="modal fade my-modal" tabindex="-1" role="dialog">
              <div class="modal-dialog" role="document">
                <div class="modal-content">

                  <div class="modal-body">
                    <object frame-resize data="www.cbu.edu.zm/downloads/pdf-sample.pdf" type="application/pdf" width="200px" height="200px"></object>
                  </div>

                </div>
              </div>
            </div>

结果:我收到以下错误:

offsetParent is not set -- cannot scroll viewer.js:150:5
scrollIntoView() viewer.js:150
PDFViewer_scrollPageIntoView() viewer.js:4880
pagechange() viewer.js:7394
PDFViewer.prototype.currentPageNumber() viewer.js:4558
pdfViewSetInitialView() viewer.js:6697
resolved()
PDF 0bf9e083c3a94f2cd2e1740080c8c88c [1.4 Acrobat Distiller 7.0.5 (Windows) / Adobe Acrobat 7.0] (PDF.js: 1.1.215)
TypeError: canvas._viewport is undefined
NotFoundError: Node was not found

我怎样才能将其嵌入模式对话框中?

有趣的是,当我关闭模式对话框并再次打开它时,pdf 会正确呈现!

更新:

解决方案:我的 css 标记如下:

html {
  overflow-y: scroll;
}

这是为了防止当网页超出可见内容高度时内容发生移动。

问题:有人知道如何保留此标签,并仅在模式窗口中忽略它吗?

最佳答案

将模态对话框的转换属性更改为无。

.modal-dialog {
  transform: none;
}

关于javascript - 如何在 Bootstrap 模式对话框中嵌入外部 pdf?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33432336/

相关文章:

.net - 使asp.net服务器控件跨浏览器兼容

javascript - Node.js 循环和 JSON 构建

jquery - 使用切换来单击元素并显示/隐藏其正下方的元素?

javascript - Angular 1.5 : pass attribute to component

javascript - 在 div 上阻止选择允许在 div 周围选择

javascript - 保持复选框被选中,刷新并提交后

javascript - 下拉弹跳问题

html - 嵌套 ng-repeat 无法正常工作

angularjs - AngularJS中的全局错误处理

javascript - 如何让这个倒数计时器倒计时到特定日期,而不仅仅是从一个时间开始?