function showPDF(pdfUrl) {
var iframe = document.getElementById("pdfFrame");
iframe.style.display = "block";
iframe.src = pdfUrl;
document.getElementById("fullscreenButton").style.display = "block";
iframe.scrollIntoView({
behavior: 'smooth',
block: 'start',
});
}
function openNewWindow() {
var iframe = document.getElementById("pdfFrame");
var pdfUrl = iframe.src;
window.open(pdfUrl, '_blank');
}
pdf 链接位于名为 pdfList 的列表中。
<a class="pdf-link" href="#" onclick="showPDF('https://www.africau.edu/images/default/sample.pdf')">pdf</a>
当我右键单击并在新选项卡中打开时,它会打开同一页面而不是 pdflink
删除脚本并让浏览器按预期处理它。
<a class="pdf-link" href="https://www.africau.edu/images/default/sample.pdf" target="_blank">Open PDF in New Tab</a>