Print HTML page in mobile browsers

Asked

Viewed 890 times

4

I’m building a system that will work on the web in PHP, where I have to make some impressions of some vouchers. The system can print the pages in HTML when I am on the computer, when I am accessing the system by a Smartphone or tablet the print function does not work. The button appears, shows that it is clicked, but nothing happens. The command I’m using is this:

<a onclick="window.print()" class="btn btn-primary no-print">Imprimir</a>

My question is whether this print function is generic, or is there a specific one for mobile devices.

  • tried to run the window.print() using the version 46.0.2490.76 from Chrome to Android, and the print screen appeared normally. but depending on your browser version, you will need to use the Google Cloud Print, as for iOS, I believe it already supports the windows.print() a long time ago, but I do not know how many WP will go in this direction.

  • My reply was not valid @Joséallison. If not, how can I improve it?

  • I’ll test and give you an answer @Danilo.

  • Okay. I’ll be waiting...

  • @Danilo. Works on some devices, as I might notice, on Android devices version 4.3+. =/

  • Only in versions higher than 4.3 android? I didn’t understand very well.

  • @Tobymosque. This is the version of my google Chrome and it doesn’t work. I updated it to a later version and it didn’t work either. I don’t know if it has anything to do with the Android version =/

  • This @Danilo. I’m running tests here on a tablet and on a mobile phone, both in version 4.3. In versions higher than this (I tested on a Motog version 5.0) and worked normally.

Show 3 more comments

1 answer

1

You can put it in href itself

<a href="javascript: window.print();" class="btn btn-primary no-print">Imprimir</a>

JSFIDDLE:

http://jsfiddle.net/0t27oovt/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.