我有一个外部 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/