1

In my website, if I click on the print button which is

<button class="btn btn-success float-right print_btn" onclick="window.print()">
<i class="fas fa-print">
</i><span class="bold">Print</span>
</button>

it's showing nothing after updating chrome 77. and on the console if I use window.print(); it is showing undefined why so?

I have also noticed one thing that if I copy the link and paste in another tab it's working fine. but the link is dynamically generated.

enter image description here

Pardeep
  • 2,153
  • 1
  • 17
  • 37
Rahul Dey
  • 48
  • 1
  • 6
  • Hi rahul, the onclick event is working for you? why am asking you is I copied your code and tried with same chrome version it works for me. Please check your chrome settings if the javascript is enabled or not? – parthicool05 Sep 24 '19 at 07:11
  • no, it is not working – Rahul Dey Sep 24 '19 at 07:13
  • This question was already answered on [this link](https://stackoverflow.com/questions/18240001/print-function-in-chrome-no-longer-working) please refer to. – Houssein Zouari Sep 24 '19 at 08:02

2 Answers2

0

Please check it in chrome settings if the javascript is enabled or blocked? If it is blocked please allow the javascript in your browser.

"chrome://settings/content/javascript"

enter image description here

parthicool05
  • 255
  • 1
  • 10
0

I had the same issue. It was working on my local version but not on the production URL. I checked site settings to make sure it wasn't blocking anything:

  • chrome://settings/content/javascript
  • chrome://settings/content/siteDetails?site=https%3A%2F%2Fstackoverflow.com

I did notice that pop-ups were blocked, so I reloaded the tab as requested but it still didn't work. I deleted my session and that didn't work. Finally I restarted Chrome and that worked.

Incidentally, when it wasn't working window.print(); immediately returned undefined in the console. Once I got it working window.print(); launched the dialog and cancelling it returned undefined in the console.

xylar
  • 7,433
  • 17
  • 55
  • 100