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?
In the Chrome browser, select the three vertical dots in the upper-right corner. Choose Settings > Advanced > Privacy and security. Select Site Settings > PDF documents. Use the toggle switch next to Download PDF files instead of automatically opening them in Chrome to turn the feature on and off.
You just need an anchor ( <a> ) element with three important attributes: The href attribute set to the URL of the page you want to link to. The target attribute set to _blank , which tells the browser to open the link in a new tab/window, depending on the browser's settings.
You should do it this way (during the onClick event):
window.open("https://www.workbooks.com/case-studies",'_blank');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With