I have a page that uses window.print(); which is already printed in the source.
But I want for a certain situation via a link trigger, maybe, to nullify/abort this command.
Basically telling the page not to launch print dialog when something is clicked to launch the page.
Maybe with window.close();, but no idea where to put, because the page has already printed window.print();
Allow me to clarify:
page ‘MYPAGE’ has window.print(); printed in the source.
- Link A opens a new page ‘MYPAGE’, and launches a Print dialog. Expected.
- Link B wants to open the same page (‘MYPAGE’) for different usage, but do not want the Print dialog.
Is it possible with jQuery?
Pass a variable into the URL and use
window.location.search.substring(1).indexOf('print') != -1to see if it has print in the URL and use a condition to block it.Or instead of blocking it later, if you anticipate that you won’t need the
window.print()command again on that page, you can just dowindow.print = function() { }before yourwindow.print()and it won’t do anything (based on whether print is in the query string)