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

时间:2015-06-03 15:28:07

标签: javascript jquery html5 css3 pdf

点击PDF下载链接后,我希望 pdf显示在同一个标​​签页中,并在第二个标签页中加载要加载的页面/案例研究

这可能吗?

目前我已经:

<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>

然而,这会在第二个标签中打开重定向,但由于主窗口让访问者感到困惑(就像在IE或FF上一样),他们不会在第一个标签中打开PDF。

有什么建议吗?

1 个答案:

答案 0 :(得分:6)

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

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