简体   繁体   English

打开新选项卡并同时下载PDF

[英]Open a new tab and download a PDF at the sametime

On clicking a PDF download link, I'd like the pdf to be displayed in that same tab and in a second tab the page /case-studies to load . 在单击PDF下载链接时,我希望pdf显示在同一个选项卡中,并在第二个选项卡中显示要加载的页面/案例研究

Is this possible? 这可能吗?

Currently I've got: 目前我有:

<h2 style="text-align: center;"><a href="http://cdn2.hubspot.net/hub/155045/file-847580737-pdf/Stepping_into_a_new_age_of_marketing_with_CRM_FINAL_APPROVED.pdf" id="pdflink" target="_blank" download=""><strong>Click here to download your eBook</strong></a></h2>
<script type="text/javascript">// <![CDATA[
document.getElementById("pdflink").onclick = function () {
        location.href = "https://www.workbooks.com/case-studies";
    };
// ]]></script>

However this opens the redirect in a second tab but as the main window confusing the visitor (as if on IE or FF) they don't release the PDF has opened in the first tab. 但是,这会在第二个选项卡中打开重定向,但由于主窗口使访问者感到困惑(就好像在IE或FF上),他们不会释放PDF已在第一个选项卡中打开。

Any advice? 有什么建议?

你应该这样做(在onClick事件期间):

window.open("https://www.workbooks.com/case-studies",'_blank');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM