The page has to have two print versions. One with price and on without. My solution works in Firefox, but not in chromebased Browser.
What I do: If the printlink is klicked, I add the print:hidden-class
name, then print, then remove the class:
<a href="javascript:if(window.print){document.getElementById('priceinfo').classList.add('print:hidden'); window.print(); document.getElementById('priceinfo').classList.remove('print:hidden');} ">print without price</a>
Why ist this not working in Edge or Chrome? And what will work?
Thanks @Fractalism moving the code into script tags worked:
<script>
document.querySelector('#print-no-price').addEventListener('click', () => {
if(window.print) {
document.getElementById('priceinfo').classList.add('print:hidden');
window.print();
document.getElementById('priceinfo').classList.remove('print:hidden');
}
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.