Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: Print (to printer...) from var?

I have something like this on a $.ajax() success function:

var popup = window.open('',titulo,"menubar=0,location=0,height=500,width=800");
popup.document.write(response);
popup.print();

My problem is that some browsers block popups, and my only need is to print.
I've found jqPrint, it is a jQuery plugin that prints from elements using an iframe.

And I do not want to load another plugin... :/

Can anybody help me?

Thanks in advance

like image 616
cusspvz Avatar asked Dec 06 '25 07:12

cusspvz


1 Answers

Maybe the fastest way is to inject the html into an hidden iFrame and print it's content.

like image 155
mamoo Avatar answered Dec 07 '25 20:12

mamoo