Changing iframe src causes browser tab to close

I have an iframe which loads a PDF src link from my backend that triggers a Print Action once the src is loaded it works as intended when loading the page normally.

<iframe id="iFramePdf" src="/empty.html" onload="printPDF();"></iframe>

However when I try to open a new tab using a hyperlink once the iframe src is loaded it causes the whole app to crash (browser tab automatically closed)

<a href="<LINK TO PAGE WITH IFRAME PDF TO PRINT>" target="_blank">

Note: There is no console error shown.