0

I have created JS Code for Printing Single Id's . When ever i try to Print Document Print button is Also comes in Preview. i tried Every Possible Solution But nothing Is Worked

i tried

@media print {
  .noprint {
    visibility: hidden;
  }
}

But No Results

Here Is My js code

        function bookListPrintOnlyId(bookid) {
        
        var popupWin = window.open('', '', 'width=700,height=700');
        popupWin.document.open();
        popupWin.document.write('<html><head><title></title>');
        popupWin.document.write('<link href="{$resourcePath}assets/css/customprint.css" rel="stylesheet" type="text/css" />');
        popupWin.document.write('</head><body ><div id="printabelDivOutput" class="printabelEquipmentsDivOutput"><table class="table table-striped table-bordered table-responsive"><thead class="table-vertical-header" style="height: 56px;"><tr><th style="width: 130px;" class="text-center"><span class="header-cell">Equipment ID</span></th></tr></thead><tbody>');
        popupWin.document.write('<tr><td class="text-center">'+bookid+'</td></tr>');
        popupWin.document.write('<tr><td class="text-center"><button onclick="window.print()" class="noprint">Print</button></td></tr>');
        popupWin.document.write('</tbody></table></div></body></html>');
        popupWin.document.close();
    }
nik708
  • 11
  • 2
  • Did you try `display: none;` instead? `visibility: hidden;` only _visually_ conceals it, and there are a few other nuanced differences from `display: none;` — see [this Stack Overflow Q&A](https://stackoverflow.com/questions/133051/what-is-the-difference-between-visibilityhidden-and-displaynone) – Bumhan Yu Feb 28 '22 at 05:27
  • Thank you for your Response. I tried but not working. – nik708 Feb 28 '22 at 05:38
  • Check out this question https://stackoverflow.com/questions/355313/how-do-i-hide-an-element-when-printing-a-web-page – Bumhan Yu Feb 28 '22 at 05:42
  • Tried Everything But Not Working. Css is not applied on Button – nik708 Feb 28 '22 at 06:14
  • Just to clarify, did you actually try _printing_ it and the button shows up on print? `@media print` only targets the printed medium, which means it won't affect on-screen preview. – Bumhan Yu Feb 28 '22 at 06:18
  • Yes, the Button Shows up on print – nik708 Feb 28 '22 at 07:05

0 Answers0