Reputation: 165
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.
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.
Any advice?
Upvotes: 5
Views: 21727
Reputation: 465
You should do it this way (during the onClick event):
window.open("https://www.workbooks.com/case-studies",'_blank');
Upvotes: 11