<iframe src="http://127.0.0.1:5500/html/PDF.js/web/viewer.html?file=http://127.0.0.1:5500/html/20210609.pdf"
frameborder="0" id="ifr" width="100%"></iframe>
<script>
// 计算页面的实际高度,iframe自适应会用到
function calcPageHeight(doc) {
var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight)
var height = Math.max(cHeight, sHeight)
return height
}
window.onload = function () {
var height = calcPageHeight(document)
parent.document.getElementById('ifr').style.height = height + 'px'
}
</script>
iframe宽度高度自适应
最新推荐文章于 2022-09-24 14:09:03 发布